[英]How to rsync with a non-standard port and two factor 2FA authentication?
I need to rsync to a remote server using a non-standard SSH port and 2FA which I use via Authy app. 我需要使用通过Authy应用程序使用的非标准SSH端口和2FA rsync到远程服务器。 The SSH works with this command:
SSH使用以下命令:
ssh -2 -p 9999 -i /Users/Me/.ssh/id_rsa user@9.9.9.9
This brings up a "Verification Code" prompt in the shell. 这会在外壳程序中弹出“验证码”提示。 Which I enter from Authy, and I'm in.
我是从Authy输入的,现在我在。
Given the discussion on this a StackOverflow answers I tried this variation of rsync: 鉴于此讨论一个StackOverflow的答案,我试过的rsync的这种变化:
rsync -rvz -e 'ssh -p 9999 -i /Users/Me/.ssh/id_rsa \
--progress /src/ user@9.9.9.9.9:/dest/
(Put here on two lines just for legibility, it's one line in my shell command). (为了清晰起见,在此放置两行,这是我的shell命令中的一行)。
This does bring up the Verification Code prompt, which I enter correctly, but then it produces this error: 这确实会弹出我输入正确的“验证码”提示,但随后会产生此错误:
protocol version mismatch -- is your shell clean?
(see the rsync man page for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(185) [sender=3.1.3]
How can I use rsync with 2FA? 如何在2FA中使用rsync? Many thanks.
非常感谢。
Because @JGK mentioned the answer in the comment, adding answer here for posterity. 由于@JGK在评论中提到了答案,因此在此添加答案以供后代使用。 This "is your shell clean" stuff is shown when remote server is echoing some output upon login, which in my case
.bashrc
indeed was. 当远程服务器在登录时回显某些输出时(在我的情况下,
.bashrc
实际上是),将显示“您的外壳是否干净”的东西。 I've added a conditional to that echo only to apply when the shell login is "interactive", as mentioned in this Server Fault thread , and it works. 我已在该回显中添加了一个条件,仅在shell登录为“交互式”时才适用, 如此Server Fault线程所述 ,并且它可以工作。 Just for easier clarity, the IF condition reads as follows:
为了更清楚起见,IF条件如下:
if echo "$-" | grep i > /dev/null; then
[any code that outputs text here]
fi
Many thanks. 非常感谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.