SSH
SSH, and Solutions.
Permission denied (publickey)
:
:SSH,,
Solutions:
- : ssh user@host 'cat ~/.ssh/authorized_keys'
- : chmod 600 ~/.ssh/id_ed25519( 600)
- .ssh : chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
- : ssh -i ~/.ssh/correct_key user@host
- -v : ssh -v user@host, Offering public key
- : PubkeyAuthentication yes( /etc/ssh/sshd_config)
: ssh-copy-id and, ~/.ssh/config Host IdentityFile
ssh: connect to host xxx port 22: Connection refused
:
:SSH,
Solutions:
- SSH : systemctl status sshd service ssh status
- SSH : sudo systemctl start sshd
- SSH : ss -tlnp | grep ssh, ssh -p
- : sudo ufw status sudo iptables -L -n | grep 22
- : sudo ufw allow 22/tcp sudo firewall-cmd --add-port=22/tcp --permanent
- , / ACL SSH
: SSH (systemctl enable sshd), SSH
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! ... Host key verification failed.
:
:known_hosts, IP,
Solutions:
- /, : ssh-keygen -R hostname
- New, New : ssh user@host
- IP (New),
- , Contact
- known_hosts : vim ~/.ssh/known_hosts, IP
:. ssh-keyscan New. StrictHostKeyChecking=no,
ssh: connect to host xxx port 22: Connection timed out
:
:, (DROP REJECT),
Solutions:
- : ping host
- : telnet host 22 nc -zv host 22
- , VPN
- traceroute host
- , IP SSH
: ~/.ssh/config ConnectTimeout 10 and more. ServerAliveInterval 60. /
Received disconnect from host: Too many authentication failures
:, SSH
:ssh-agent, SSH MaxAuthTries
Solutions:
- ~/.ssh/config : IdentityFile ~/.ssh/specific_key
- IdentitiesOnly yes agent
- agent : ssh-add -D
- : ssh -o IdentitiesOnly=yes -i ~/.ssh/key user@host
- (Recommended): MaxAuthTries 6( /etc/ssh/sshd_config)
: ~/.ssh/config Host IdentityFile and IdentitiesOnly yes, SSH. agent Common