Ssh

如何在本地 macOS 上通過 SSH 正確使用 rsync Push 到遠端 Debian

  • December 24, 2017

我已經嘗試讓 rsync 工作了幾個小時,但運氣不佳😣。我有一個數字海洋水滴,我想使用 SSH 通過 rsync 發送文件。

在通過自製軟體安裝的 macOS 10.12.6 上執行的本地 rsync

rsync version 3.1.2 protocol version 31

在通過 apt 安裝的 Debian 8.x 上執行的遠端 rsync

rsync version 3.1.1 protocol version 31

我正在嘗試將單個文件從本地 macOS 盒子發送到遠端 Debian 盒子(Digital Ocean droplet) 我在 macOS 上的終端​​本地發出的命令

$ rsync -avvvv -e "ssh -p $SSH_PORT_# -v" dummy $USER@example.com:/home/$USER/www/

一些花絮,

  1. dummy 是我本地系統上的單個 10MB 文件。

2)我可以使用以下命令在遠端數字海洋中成功ssh, $ ssh nathan 2.1) I have a “config” file in /Users/ $ USER/.ssh/

2.2) /Users/$USER/.ssh/config 的內容

主機 nathan 主機

名 $ REMOTE_IP_ADDRESS i.e. 1.2.3.4 User $ REMOTE_USERNAME 克里斯

埠 $ SSH_PORT_# 4242 IdentityFile /Users/ $ 使用者/.ssh/id_rsa

  1. 我也可以使用以下命令 ssh 進入遠端 Digital Ocean 液滴

$ ssh -l $USER -p 4242 $REMOTE_USERNAME example.com

執行上述 rsync 命令的一些輸出,使用以下命令

打開連接:ssh -p 4242 -v -l $ USER example.com rsync –server -vvvvlogDtpre.iLsfxC . /home/ $ USER/www/ (12 args)

msg​​ 檢查字元集: UTF-8

OpenSSH_7.4p1, LibreSSL 2.5.0

debug1: Reading configuration data /Users/ $ USER/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to example.com [1.2.3.4] port 4242. debug1: Connection established. debug1: Local version string SSH-2.0-OpenSSH_7.4 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Debian-5+deb8u4 debug1: match: OpenSSH_6.7p1 Debian-5+deb8u4 pat OpenSSH* compat 0x04000000 debug1: Authenticating to example.com:4242 as ’ $ USER'

debug1: SSH2_MSG_KEXINIT sent

debug1: SSH2_MSG_KEXINIT received

debug1: kex: algorithm: curve25519-sha256@libssh.org

debug1: kex: host key algorithm: ecdsa-sha2-nistp256

debug1: kex: server->client cipher: chacha20-poly1305@ openssh.com MAC:壓縮:無

調試1:kex:客戶端->伺服器密碼:chacha20-poly1305@openssh.com MAC:壓縮:無

調試1:期待SSH2_MSG_KEX_ECDH_REPLY

調試1:伺服器主機密鑰:ecdsa-sha2-nistp256 SHA256:REMOVED_KEY

調試1:主持人 '

$$ example.com $$:4242’ 是已知的並且匹配 ECDSA 主機密鑰。

debug1:在 /Users/ 中找到密鑰 $ USER/.ssh/known_hosts:15 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: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/ $ USER/.ssh/id_rsa

debug1:伺服器接受密鑰:pkalg ssh-rsa blen 279

debug1:身份驗證成功(公鑰)。

已通過 example.com 驗證($$ 1.2.3.4 $$:4242)。

調試1:通道0:新$$ client-session $$

debug1:請求 no-more-sessions@openssh.com

debug1:進入互動式會話。

debug1:承諾:網路

debug1:發送命令:rsync –server -vvvvlogDtpre.iLsfxC –log-format=%i 。/home/$USER/www/

(客戶端)協議版本:遠端=31,協商=31

到目前為止,我可以使用上面的 rsync 命令 😭 如果您有任何想法/建議,我一定會喜歡 ❤️ 聽到它們。

乾杯🍺克里斯

TLDR;該問題與我的config.fish文件有關。

我是如何最終達成決議的。

我決定進行健全性檢查以在兩台機器上創建一個新使用者,並使用新創建的使用者帳戶測試 rsync / scp。低和看哪都最終工作了。

我最終嘗試的事情是,重新啟動遠端機器,通過傳遞標誌以單使用者模式啟動 sshd -vvvv,篩選日誌並且看不到與文件發送不正確相關的任何內容。

我可以在本地訪問的唯一另一台電腦是 RasPi,所以我嘗試 scp / rsync 本地到 RasPi,它結束了工作,所以我推斷它必須對伺服器上的配置文件做一些事情。

引用自:https://serverfault.com/questions/888936