Creating and Using SSH Keys Securely
SSH public-key authentication uses a mathematically related public and private key pair. The public key is installed for the destination account, while the private key stays on the administrator's device. The server verifies possession without receiving the private key itself. This approach can reduce exposure to password guessing, support automation, and provide per-person access. A stolen or unprotected private key nevertheless remains a serious credential risk.
Generate the pair safely
Ed25519 is a common choice when modern client and server compatibility is available. An up-to-date policy may require RSA with an adequate key size for older or specialized compatibility. For example, an OpenSSH client can run ssh-keygen -t ed25519 -a 64 -C "device-and-user-label". Do not accidentally overwrite an existing key file. Protect the private key with a strong passphrase, or follow the relevant process when a hardware-backed key or enterprise vault is used. The public .pub file may be distributed; the private-key file must not be shared.
Deploy, test, and harden access
Add the public key to the correct Unix account's ~/.ssh/authorized_keys, the control panel's key manager, or the provider's documented mechanism. SSH may reject the key when home-directory, .ssh, file ownership, or permissions are too permissive. Test a new connection with verbose client output while keeping the existing administrative session open. Disabling password authentication or narrowing firewall rules before key access is proven can lock out the operator. Confirm console or recovery access first.
On the first connection, verify the server host-key fingerprint through a trusted channel. Blind acceptance can conceal a machine-in-the-middle risk. In client configuration, define the hostname, user, port, and identity file explicitly; obtain the port from the selected product and server record. If an agent caches unlocked keys, consider its lifetime and which local processes can request signatures. Generate keys per person and device instead of circulating a shared private key. Remove a public key when staff leave or a device is lost, review access logs, and maintain an owner and expiry inventory.
For automation, restrict the account and key to the smallest necessary commands and sources when the platform supports those controls. Test rotation before deleting the previous key, and never place private keys in source repositories, ticket bodies, or unprotected backups.
Practical checklist
- Choose a compatible algorithm and create a descriptive key label.
- Protect the private key with a passphrase and restrictive permissions.
- Install the public key for the correct account and ownership.
- Test new access and recovery before closing the current session.
- Verify host keys and maintain per-person rotation and revocation.
SSH Anahtarı Oluşturma ve Güvenli Kullanım Rehberi
SSH anahtar tabanlı kimlik doğrulama, birbiriyle matematiksel olarak ilişkili açık ve özel anahtar çifti kullanır. Açık anahtar hedef hesaba eklenir; özel anahtar yönetici cihazından ayrılmaz. Sunucu, özel anahtarın kendisini almadan istemcinin ona sahip olduğunu doğrular. Bu yöntem güçlü parola denemelerine maruz kalmayı azaltabilir, otomasyonu kolaylaştırabilir ve kişi bazlı erişim sağlar; ancak çalınmış veya korumasız bir özel anahtar yine ciddi risktir.
Anahtar çiftini güvenli oluşturun
Modern istemci ve sunucu uyumluluğu varsa Ed25519 yaygın bir seçenektir; eski veya özel uyumluluk gereksinimlerinde güncel politika ve yeterli anahtar boyutuyla RSA gerekebilir. Örneğin OpenSSH istemcisinde ssh-keygen -t ed25519 -a 64 -C "cihaz-ve-kullanici-etiketi" komutu kullanılabilir. Dosyayı mevcut bir anahtarın üzerine yanlışlıkla yazmayın. Özel anahtarı güçlü bir parola ile koruyun; güvenli donanım veya kurumsal anahtar kasası kullanılıyorsa ilgili prosedürü izleyin. Açık anahtarın .pub dosyası paylaşılabilir, özel anahtar dosyası paylaşılmaz.
Dağıtım, test ve sertleştirme
Açık anahtarı doğru Unix hesabının ~/.ssh/authorized_keys dosyasına, panelin anahtar yönetimine veya sağlayıcının belgelenmiş mekanizmasına ekleyin. Ev dizini, .ssh dizini ve dosya sahipliği ya da izinleri fazla genişse SSH anahtarı reddedebilir. Yeni bağlantıyı ayrıntılı istemci çıktısıyla test edin ve mevcut yönetim oturumunu açık tutun. Anahtar erişimi kesin olarak çalışmadan parola girişini kapatmak veya güvenlik duvarını daraltmak kendinizi sunucu dışında bırakabilir. Konsol ya da kurtarma yolunu önceden doğrulayın.
İlk bağlantıda gösterilen sunucu host key parmak izini güvenilir bir kanaldan doğrulayın; körlemesine kabul etmek aradaki kişi riskini gözden kaçırır. İstemci yapılandırmasında sunucu adı, kullanıcı, port ve anahtar dosyasını açıkça tanımlayın; port değeri seçilen ürün ve sunucu kaydından alınmalıdır. Agent kullanıyorsanız kilit süresi ve hangi süreçlerin anahtarı isteyebildiğini değerlendirin. Anahtarları kişi ve cihaz bazında üretin, ortak özel anahtar dağıtmayın. Ayrılan personelin veya kayıp cihazın açık anahtarını kaldırın, erişim günlüklerini inceleyin ve düzenli envanter tutun.
Pratik kontrol listesi
- Uyumlu algoritma seçip anahtarı açıklayıcı etiketle oluşturun.
- Özel anahtarı parola ve sınırlı dosya izinleriyle koruyun.
- Açık anahtarı doğru hesapta sahiplik ve izinleriyle kurun.
- Mevcut oturumu kapatmadan yeni bağlantı ve kurtarma yolunu test edin.
- Host key doğrulama, kişi bazlı envanter ve iptal süreci uygulayın.