免密登录不生效的原因
前提公钥已经设置到authorized_keys中
创建authorized_keys文件:
touch ~/.ssh/authorized_keys
原因1: 权限过大
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
查看详细登录日志
ssh -v your_login_name@your_ip or node_name
比如我遇到的问题就是权限过大以及使用ed25519秘钥,默认使用的id_rsa
比如你使用id_ed25519私钥,但是实际用的是id_rsa
这个需要.ssh/config新增配置文件去指定
Hostname node152
IdentityFile ~/.ssh/id_ed25519
Host *
AddKeysToAgent yes
IgnoreUnknown UseKeychain
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519

当SSH免密登录不起作用时,可能的原因包括权限设置不正确(如.ssh目录权限过大或authorized_keys文件权限过宽)以及使用了非默认的密钥文件(如id_ed25519而非id_rsa)。解决方法包括调整权限至适当值(如chmod700.ssh,chmod600.ssh/authorized_keys)并在.ssh/config文件中指定使用特定的IdentityFile。此外,确保配置文件中的Host设置匹配服务器名称或IP,以使SSH知道使用哪个密钥。
1441

被折叠的 条评论
为什么被折叠?



