Computer Science Radar

SSH

/etc/ssh/sshd_config

ssh -v <user>@<host> 输出详细的 debug 信息。

ssh-keygen

ssh-copy-id

修改配置文件后需要重启 ssh 服务。

sudo service ssh restart/sudo systemctl restart sshd

PasswordAuthentication

FAQs§

连接速度慢§

  1. 关闭 DNS 反向解析,UseDNS no
  2. 关闭 SERVER 上的 GSS 认证,GSSAPIAuthentication no

Permission denied (publickey)§

确认添加公钥无误,sshd_config中的路径也是正确的。

有一个很难发现的问题,就是~/.ssh目录下的权限设置,非常严格。

# paste these into an SSH session that server (probably from
# another user account or root)

# change this to YOUR username on the server.
UN=example

# paste these lines verbatim:
sudo chown $UN:$UN /home/$UN/{.,.ssh/,.ssh/authorized_keys}
sudo chmod u+rwX,go-rwX,-t /home/$UN/{.ssh/,.ssh/authorized_keys}
sudo chmod go-w /home/$UN/

Reference§

  1. sshd - SSH-Key authentication fails - Super User