![SSH 公钥未发送到服务器](https://linux22.com/image/15667/SSH%20%E5%85%AC%E9%92%A5%E6%9C%AA%E5%8F%91%E9%80%81%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8.png)
我在以下方面遇到困难,我正在尝试为 rsync 配置一个 cron 作业以在两个服务器之间同步,为此我需要服务器 A(本地)使用公钥 ssh 到服务器 B。
我之前通过以下方式添加了无密码和无密码连接:
I. 通过 SSH 使用 Key Agent 免费设置 PassPhrase
- 重新启动 SSH 密钥代理
- 评估 ssh-agent -s
- 添加私钥
- ssh-添加 ~/.ssh/id_rsa_abc
调试信息
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug2: key: /home/groups/user/.ssh/id_rsa_abc (0x55ad08946370), explicit
debug3: send packet: type 5 debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/groups/user/.ssh/id_rsa_abc
debug3: send_pubkey_test debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg rsa-sha2-512 blen 535
debug2: input_userauth_pk_ok: fp SHA256:PYUC9QpfCGMZ8DOvOF944bFHchCNJyNRS2G+wjDXRKQ
debug3: sign_and_send_pubkey: RSA SHA256:PYUC9QpfCGMZ8DOvOF944bFHchCNJyNRS2G+wjDXRKQ
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug2: no passphrase given, try next key
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey). ssh_exchange_identification:
Connection closed by remote host ssh_exchange_identification:
Connection closed by remote host
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
公钥位于 ~/.ssh/(即 /root/.ssh)中,并且服务器 A 和 B 上的所有文件权限都是正确的。
我如何运行 rsync 命令:
rsync -avP --stats --log-file=rsync.log -e 'ssh -p 22 -vvv' source_dir user@serverA:target_dir