1

I've got a script that needs to rsync some files to a remote machine. The rsync command looks like this:

rsync -avz -e 'ssh -vv -o IdentitiesOnly=yes -i /data/credentials/rsync2.key' \
   --rsync-path="mkdir -p ~/new_data/12345/ && rsync" \
   /data/new_data/  some_user@$REMOTE_HOST_IP:~/new_data/12345/

The output from the script looks like:

...
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 134/256
debug2: bits set: 505/1024
debug1: Server host key: RSA XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
debug1: read_passphrase: can't open /dev/tty: No such device or address
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]

It looks to me like ssh is trying to use a passphrase on the key. It shouldn't, the key doesn't require a passphrase. Also, I'm pretty sure that the message about /dev/tty is not entirely accurate since my script confirms that /dev/tty exists (ls -l on it shows: crw-rw-rw- 1 root root 5, 0 Feb 23 19:37 /dev/tty). I also know the keyfile is valid since I can manually connect to the remote host via ssh using the key.

The one catch here is that my script is running within a docker container and I'm not sure how that may affect rsync and ssh.

  • 1
    What happens when you try to ssh -vv -o IdentitiesOnly=yes -i /data/credentials/rsync2.key some_user@$REMOTE_HOST_IP by itself without the context of rsync? – DopeGhoti Feb 23 '16 at 19:50
  • Looks like a wrong key format. How did you get/create the key? – Jakuje Feb 23 '16 at 19:59
  • @DopeGhoti: Same result, minus the rsync error. When I execute the command outside of a docker context, it works fine. – FrustratedWithFormsDesigner Feb 23 '16 at 20:04
  • 1
    You could try passing the -T argument to your ssh command, which will disable tty allocation. – Thomas N Feb 23 '16 at 21:07

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.