SSH (Secure Shell) , uzak sunuculara güvenli erişim için kullanılan protokoldür. Bug bounty ve pentest'lerde hem hedef sistemlere erişim hem de kendi sunucularınızı koruma için kritik öneme sahiptir.
# /etc/ssh/sshd_config
# Temel güvenlik
Port 2222 # Varsayılan portu değiştir
PermitRootLogin no # Root login engelle
PasswordAuthentication no # Şifreli login engelle
PubkeyAuthentication yes # Sadece key ile
ChallengeResponseAuthentication no
UsePAM no
# Ek güvenlik
MaxAuthTries 3 # Maksimum deneme
MaxSessions 2 # Maksimum oturum
ClientAliveInterval 300 # Boşta kalma süresi
ClientAliveCountMax 2 # Maksimum boşta kalma
AllowUsers kullanici # Sadece belirli kullanıcılar
DenyUsers root
# SSH key oluştur
ssh-keygen -t ed25519 -a 100
ssh-keygen -t rsa -b 4096
# Public key'i sunucuya kopyala
ssh-copy-id user@host
# veya manuel
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# Key izinleri
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/authorized_keys
# Local port forwarding
ssh -L 8080:localhost:80 user@host
# Remote port forwarding
ssh -R 8080:localhost:80 user@host
# Dynamic port forwarding (SOCKS)
ssh -D 1080 user@host
# Sadece tunneling
ssh -N -L 8080:localhost:80 user@host
SSH Güvenli Yapılandırması
bash# /etc/ssh/sshd_config
# Temel güvenlik
Port 2222 # Varsayılan portu değiştir
PermitRootLogin no # Root login engelle
PasswordAuthentication no # Şifreli login engelle
PubkeyAuthentication yes # Sadece key ile
ChallengeResponseAuthentication no
UsePAM no
# Ek güvenlik
MaxAuthTries 3 # Maksimum deneme
MaxSessions 2 # Maksimum oturum
ClientAliveInterval 300 # Boşta kalma süresi
ClientAliveCountMax 2 # Maksimum boşta kalma
AllowUsers kullanici # Sadece belirli kullanıcılar
DenyUsers root
SSH Key Yönetimi
bash# SSH key oluştur
ssh-keygen -t ed25519 -a 100
ssh-keygen -t rsa -b 4096
# Public key'i sunucuya kopyala
ssh-copy-id user@host
# veya manuel
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# Key izinleri
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/authorized_keys
SSH Port Forwarding (Tunnel)
bash# Local port forwarding
ssh -L 8080:localhost:80 user@host
# Remote port forwarding
ssh -R 8080:localhost:80 user@host
# Dynamic port forwarding (SOCKS)
ssh -D 1080 user@host
# Sadece tunneling
ssh -N -L 8080:localhost:80 user@host
SSH Güvenlik Kontrol Listesi
- PasswordAuthentication no
- PermitRootLogin no
- PubkeyAuthentication yes
- Port değiştirildi mi?
- Fail2ban kurulu mu?
- AllowUsers/DenyUsers tanımlı mı?
- Key izinleri doğru mu?
🔒 Bu içeriği görmek için giriş yapın