Support Online
Skip to main content

SSH Key Based Authentication

Using an SSH key pair instead of a password makes your server much more secure against brute force attacks.

Creating a Key Pair

###Windows (PowerShell)

ssh-keygen -t ed25519 -C "email@example.com"

###Linux/macOS

ssh-keygen -t ed25519 -C "email@example.com"

Created files:

  • ~/.ssh/id_ed25519Private key (do not share with anyone!)
  • ~/.ssh/id_ed25519.pubPublic key (will be copied to the server)

Copying Public Key to Server

Method 1: ssh-copy-id (Linux/macOS)

ssh-copy-id -i ~/.ssh/id_ed25519.pub kullaniciadi@sunucu-ip

Method 2: Manual Copy

# Açık anahtarın içeriğini görüntüleyin
cat ~/.ssh/id_ed25519.pub

# Sunucuda bu komutu çalıştırın:
mkdir -p ~/.ssh
echo "AÇIK_ANAHTAR_İÇERİĞİ" >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Update SSH Configuration

After verifying that key access is working, turn off password entry:

nano /etc/ssh/sshd_config

Change the following lines:

PasswordAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

Restart the service:

systemctl restart ssh

Connection Test

ssh -i ~/.ssh/id_ed25519 kullaniciadi@sunucu-ip
tip

~/.ssh/config dosyasına kısayol ekleyerek bağlantıyı kolaylaştırabilirsiniz:

Host rabisu-ds HostName sunucu-ip User kullaniciadi IdentityFile ~/.ssh/id_ed25519

Now you just need to type ssh rabisu-ds.