SSH to my server works. But I've enabled Multifactor authentication with Google Authenticator. So during the process of SSH, it asks for my verification code.

Issue now is I want to rsync to this server from a server located in another country. I'm trying this command:

rsync -av --progress  -e "ssh -2 -p 2299" origin.txt myuser@

Where the non-standard port is 2299 and the IP of the destination server is in this illustrative example. Challenge is that SSH is not asking me for my verification code. So rsync fails with a message like this:

ssh: connect to host port 2299: Connection timed out
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(600) [sender=3.0.6] 

Any ideas how I can enable rsync to also ask me the verification code so that this works?

  • 1
    A work-around I've used in the past is to configure a grace period where new connections established with 30s after a successful 2FA login from the same IP & user would not require 2FA again. – HBruijn Mar 24 '17 at 11:42
  • Thank you. I suppose there's that option while setting up the authentication, but that leads to a rushed stressful time for every rsync, and in any case it doesn't solve the issue of doing rsync with cron jobs as I may not be around to manually do that. In this case, is there a workaround that if I specify a command attribute, then the 2FA verification should NOT occur? – PKHunter Mar 25 '17 at 4:30
  • Or, some program on the local server that's CHMODed to only the main user on the server and can be called from rsync command at run time to do auto-generate the verification code and pass it programmatically? – PKHunter Mar 25 '17 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.