0

I need to rsync to a remote server using a non-standard SSH port and 2FA which I use via Authy app. The SSH works with this command:

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.

Given the discussion on this a StackOverflow answers I tried this variation of 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).

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? Many thanks.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Khom Nazid
  • 548
  • 1
  • 7
  • 20
  • 1
    what OS are you connecting from? Is the client openssh? – jhnc Feb 19 '19 at 05:12
  • 1
    https://serverfault.com/questions/267154/protocol-version-mismatch-is-your-shell-clean and what are the rsync versions on client and server – JGK Feb 19 '19 at 14:39
  • @jhnc I thought I had included that in the description, but apparently now. Mac OSX, latest Mojave. Not sure what the client is. It's the "Terminal" app in OSX. – Khom Nazid Feb 19 '19 at 18:25
  • Thank you @JGK - actually on the remote script I used the conditional display, only if the shell is interactive. Now `rsync` works. Many thanks! – Khom Nazid Feb 19 '19 at 19:00
  • Thank you @jww, but there are so many variations: Stack Overflow, Server Fault, Stack..XYZ, that it's hard to always know where something fits. To me server based automation of code transfers is a part of the development workflow. Anyway, it'd be great to have this tech savvy website automagically apportion questions to related forums, while keeping them accessible from anywhere. This is already happening better than a few years ago with the menu now kind of integrated. Thank you for the patience with people asking questions where they feel they belong. Not 100% accurate given grey areas.. – Khom Nazid Feb 21 '19 at 15:22

1 Answers1

0

Because @JGK mentioned the answer in the comment, adding answer here for posterity. This "is your shell clean" stuff is shown when remote server is echoing some output upon login, which in my case .bashrc indeed was. 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. Just for easier clarity, the IF condition reads as follows:

if echo "$-" | grep i > /dev/null; then
  [any code that outputs text here]
fi

Many thanks.

Khom Nazid
  • 548
  • 1
  • 7
  • 20