====== ssh ====== Siehe auch [[scp]]. ===== Allgemein ===== > ssh -l USER -p PORT DOMAIN > ssh USER@DOMAIN ===== Erzwinge Passwort-Authentifikation ===== ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no me@host ===== Removes all keys belonging to hostname from a known_hosts file. ===== This option is useful to delete hashed hosts. ssh-keygen -f "/home/me/.ssh/known_hosts" -R 192.168.0.14 ===== Keys für ein besteimmte IP entfernen ===== Warning: the ECDSA host key for 'example.com' differs from the key for the IP address '116.203.XX.XXX' Offending key for IP in /home/me/.ssh/known_hosts:58 Matching host key in /home/me/.ssh/known_hosts:3 Are you sure you want to continue connecting (yes/no)? Lösung: ssh-keygen -R 116.203.XX.XXX ===== Tunnel (Remote Port-Forwarding) ===== ==== Beispiel ==== > ssh -nNT -R \*:9000:localhost:9981 -i .ssh/example.com_id_rsa -p64000 me@example.com ===== SSH ohne Passwort ===== ==== lokal ==== **1. Zertifikat erstellen**: > ssh-keygen -b 4096 **2. Übertragen auf remote-Server:** > ssh-copy-id -i .ssh/key_rsa.pub me@example.com ==== remote ==== Falls key noch nicht übertragen: > cat key_rsa.pub >> /.ssh/authorized_keys in der /etc/ssh/sshd_config: PasswordAuthentication no ==== lokal ==== > ssh -p 64000 me@example.com ===== Fehlermeldungen ===== ==== Received disconnect from ... Too many authentication failures for ... ==== > Received disconnect from EXTERNAL_HOST: 2: Too many authentication failures for USER from LOCAL_HOST port 57684 ssh2 > Disconnected from EXTERNAL_HOST Das wird in der Regel dadurch verursacht, dass dem Server mehrere Keys angeboten werden. Der Server akzeptiert keine Schlüssel mehr, nachdem ihm zuviele Keys angeboten werden. Überprüfen läßt sich das mit dem -v Flag. === Mögliche Lösungen: === **ohne PubKey:** > ssh -o PubkeyAuthentication=no USER@EXTERNAL_HOST **mit Pubkey:** Um das zu verhindern, kann man den Key explizit in jedem Host-Eintrag in der ~/.ssh/config festlegen indem IdentitiesOnly definiert wird: Beispiel 1 > Host www.somehost.com > IdentityFile ~/.ssh/key_for_somehost_rsa > IdentitiesOnly yes > Port 22 Beispiel 2 > Host somehost > IdentityFile ~/.ssh/key_for_somehost_rsa > IdentitiesOnly yes > HostName www.somehost.com > Port 22 Fall ssh-agent verwendet wird, hilf es, ssh-add -D zu starten um die Identitäten zu säubern. Ohne die ssh-Host-Konfiguration geht das mit: > ssh -i some_id_rsa -o 'IdentitiesOnly yes' them@there:/path/ oder > ssh -i some_id_rsa -o IdentitiesOnly=yes them@there:/path/ //Von https://superuser.com/questions/187779/too-many-authentication-failures-for-username/187790#187790 // ==== Fehler: sign_and_send_pubkey: signing failed: agent refused operation ==== ssh me@host sign_and_send_pubkey: signing failed: agent refused operation me@host: Permission denied (publickey). Lösung: Problem liegt an gnome-keyring. ssh-add ~/.ssh/id_rsa ===== Siehe auch ===== * [[linux:ssh_auf_dem_server_absichern_unter_debian|SSH auf dem Server absichern unter Debian]] * [[sftp als root auf Server ohne root-ssh-Login]] * [[sshfs]]