扫码关注官方订阅号
是不是生成的id_rsa.pub都放在远程服务器的~/.ssh/authorized_keys 下就可以了? 我有一台是成功的,可是另一台怎么都不行,非要输密码, 请问这是什么情况?
ringa_lee
放在「~/.ssh/authorized_keys 下」?应该是放它里边。它应该是个文件,一行一个公钥。
授权失败的话,请检查系统日志。另外注意 ~/.ssh 的权限应该是 700,当然所有者也不能错。
首先使用ssh -i /path/to/keyfile user@host1和host2 -vvvv,分别查看你能否登录这两台机器以及成功使用的keyfile
.... debug1: Trying private key: /Users/xxx/.ssh/host1.pem debug1: read PEM private key done: type RSA debug3: sign_and_send_pubkey: RSA 30:a9:37:b5:c4:ad:8a:b4:c8:64:f7:fb:c1:7d:48:62 debug2: we sent a publickey packet, wait for reply debug1: Authentication succeeded (publickey). Authenticated to host1 ....
fabric
from fabric.api import *
env.hosts = ['host1', 'host2'] env.user = 'user' env.key_filename = '/path/to/keyfile.pem'
run('uname -a')
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
放在「~/.ssh/authorized_keys 下」?应该是放它里边。它应该是个文件,一行一个公钥。
授权失败的话,请检查系统日志。另外注意 ~/.ssh 的权限应该是 700,当然所有者也不能错。
首先使用ssh -i /path/to/keyfile user@host1和host2 -vvvv,分别查看你能否登录这两台机器以及成功使用的keyfile
....
debug1: Trying private key: /Users/xxx/.ssh/host1.pem
debug1: read PEM private key done: type RSA
debug3: sign_and_send_pubkey: RSA 30:a9:37:b5:c4:ad:8a:b4:c8:64:f7:fb:c1:7d:48:62
debug2: we sent a publickey packet, wait for reply
debug1: Authentication succeeded (publickey).
Authenticated to host1 ....
fabric
from fabric.api import *
env.hosts = ['host1', 'host2']
env.user = 'user'
env.key_filename = '/path/to/keyfile.pem'
run('uname -a')