最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Mac中sshpass加上rsync运行报错:Host key verification failed rsync error unexplained error code 255 rsync.c sender

rsync crifan 2854浏览 0评论
折腾:
【未解决】Mac中恢复crifan的gitbook的template模板环境
期间,mac安装了sshpass后,继续去运行但报错
Upload for desktop_app_framework_electron
sshpass -f /Users/xxx/dev/crifan/gitbook/gitbook_template/common/config/deploy/deploy_server_password.txt rsync -avzh --progress --stats --delete --force /Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/desktop_app_framework_electron/release/desktop_app_framework_electron root@xxx:/data/wwwroot/book.crifan.com/books
Host key verification failed.
rsync error: unexplained error (code 255) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-52.200.1/rsync/rsync.c(244) [sender=2.6.9]
make: *** [upload] Error 6
单独运行一次:
sshpass -f /Users/xxx/dev/crifan/gitbook/gitbook_template/common/config/deploy/deploy_server_password.txt rsync -avzh --progress --stats --delete --force /Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/desktop_app_framework_electron/release/desktop_app_framework_electron root@xxx:/data/wwwroot/book.crifan.com/books
结果卡死的感觉:
没有输出
过了很多分钟后,报错:
✘ xxx@xxx  ~/dev/crifan/gitbook/gitbook_template/books/desktop_app_framework_electron   master  sshpass -f /Users/xxx/dev/crifan/gitbook/gitbook_template/common/config/deploy/deploy_server_password.txt rsync -avzh --progress --stats --delete --force /Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/desktop_app_framework_electron/release/desktop_app_framework_electron root@xxx:/data/wwwroot/book.crifan.com/books
Connection closed by xxx port 22
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-52.200.1/rsync/io.c(453) [sender=2.6.9]
mac  rsync error unexplained error code 255 at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-52.200.1/rsync/rsync.c 244 sender
mac  rsync error unexplained error code 255 at rsync rsync.c  sender
Rsync error code 255 – Quick fixes
ssh – Rsync stopped working and returns “rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.2]” – Super User
此处不像是文件大和多导致的超时
ssh – Rsync creates error message unexplained error (code 255) at io.c(837) – Ask Ubuntu
加上-v去调试看看
sshpass -f /Users/xxx/dev/crifan/gitbook/gitbook_template/common/config/deploy/deploy_server_password.txt rsync -v -avzh --progress --stats --delete --force /Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/desktop_app_framework_electron/release/desktop_app_framework_electron root@xxx:/data/wwwroot/book.crifan.com/books
可以输出详情:
opening connection using ssh -l root xxx rsync --server -vvlogDtprz --delete --force . /data/wwwroot/book.crifan.com/books
好像此处应该需要:
当前mac用ssh登录一次才可以?
去看看之前自己的帖子:
【已解决】rsync同步上传出错:Host key verification failed – 在路上
去试试:
ssh -v root@xxx
输出:
 ssh -v root@xxx
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: /etc/ssh/ssh_config line 52: Applying options for *
debug1: Connecting to xxx [xxx] port 22.
debug1: Connection established.
debug1: identity file /Users/xxx/.ssh/id_rsa type -1
debug1: identity file /Users/xxx/.ssh/id_rsa-cert type -1
debug1: identity file /Users/xxx/.ssh/id_dsa type -1
debug1: identity file /Users/xxx/.ssh/id_dsa-cert type -1
debug1: identity file /Users/xxx/.ssh/id_ecdsa type -1
debug1: identity file /Users/xxx/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/xxx/.ssh/id_ed25519 type -1
debug1: identity file /Users/xxx/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/xxx/.ssh/id_xmss type -1
debug1: identity file /Users/xxx/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to xxx:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:hst3bHt/BDOXUt+D1G2su5j0U7+weGKSxEv3LY2ucbo
The authenticity of host 'xxx (xxx)' can't be established.
ECDSA key fingerprint is SHA256:hst3bHt/BDOXUt+D1G2su5j0U7+weGKSxEv3LY2ucbo.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'xxx' (ECDSA) to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: /Users/xxx/.ssh/id_rsa
debug1: Will attempt key: /Users/xxx/.ssh/id_dsa
debug1: Will attempt key: /Users/xxx/.ssh/id_ecdsa
debug1: Will attempt key: /Users/xxx/.ssh/id_ed25519
debug1: Will attempt key: /Users/xxx/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/xxx/.ssh/id_rsa
debug1: Trying private key: /Users/xxx/.ssh/id_dsa
debug1: Trying private key: /Users/xxx/.ssh/id_ecdsa
debug1: Trying private key: /Users/xxx/.ssh/id_ed25519
debug1: Trying private key: /Users/xxx/.ssh/id_xmss
debug1: Next authentication method: password
root@xxx's password:
debug1: Authentication succeeded (password).
Authenticated to xxx ([xxx]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = zh_CN.UTF-8
Last failed login: Thu Jun 18 18:07:16 CST 2020 from 222.186.30.112 on ssh:notty
There were 3489 failed login attempts since the last successful login.
Last login: Wed Jun 17 21:04:40 2020 from 114.219.20.242
然后再去试试
不过先要输入 exit去推出ssh
[root@crifan ~]# exit
登出
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to xxx closed.
Transferred: sent 2256, received 2816 bytes, in 28.1 seconds
Bytes per second: sent 80.3, received 100.2
debug1: Exit status 0
继续:
就可以了:
 sshpass -f /Users/xxx/dev/crifan/gitbook/gitbook_template/common/config/deploy/deploy_server_password.txt rsync -v -avzh --progress --stats --delete --force /Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/desktop_app_framework_electron/release/desktop_app_framework_electron root@xxx:/data/wwwroot/book.crifan.com/books
opening connection using ssh -l root xxx rsync --server -vvlogDtprz --delete --force . /data/wwwroot/book.crifan.com/books
building file list ...
193 files to consider
deleting in desktop_app_framework_electron
delta-transmission enabled
desktop_app_framework_electron/
desktop_app_framework_electron/epub/
desktop_app_framework_electron/epub/desktop_app_framework_electron.epub
       6.23M  71%    1.22MB/s    0:00:01
看来就是之前的:
rsync的Host key verification failed的问题
需要mac本地ssh连接一次服务器即可。
【总结】
此处
sshpass -f /Users/xxx/dev/crifan/gitbook/gitbook_template/common/config/deploy/deploy_server_password.txt rsync -avzh --progress --stats --delete --force /Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/desktop_app_framework_electron/release/desktop_app_framework_electron root@xxx:/data/wwwroot/book.crifan.com/books
报错:
Host key verification failed.
rsync error: unexplained error (code 255) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-52.200.1/rsync/rsync.c(244) [sender=2.6.9]
make: *** [upload] Error 6
根本原因:
还是之前就遇到过多次的:
Host key verification failed
(而不是后面的错误信息)
解决办法:
用ssh连接一次服务器:
ssh -v root@xxx
期间输入yes,再输入密码即可
注:加-v是verbose,输出详细信息,方便当错误时发现问题原因。
之后即可正常使用sshpass和rsync。

转载请注明:在路上 » 【已解决】Mac中sshpass加上rsync运行报错:Host key verification failed rsync error unexplained error code 255 rsync.c sender

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.173 seconds, using 22.17MB memory