I have somehow killed my ssh key login while tinking with rsync. Here is the rsync command I ran. (I Control-C'd as soon as I saw it working):

rsync -avz -e "ssh -i .ssh/id_rsa.pub -p XXXX" --progress ./ user@SERVERNAME/home/user/

After which I get the following error when trying to ssh in

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

the perms on the server are as follows,


drwx------  2 frank frank 4096 Nov 22 06:01 .
drwxrwxr-x 35 frank frank 4096 Nov 22 06:23 ..
-rw-------  1 frank frank 3893 Nov 22 05:50 authorized_keys
-rw-------  1 frank frank 1675 Oct 21  2016 id_rsa
-rw-r--r--  1 frank frank  397 Oct 21  2016 id_rsa.pub
-rw-r--r--  1 frank frank  420 Nov 22 06:26 known_hosts


drwx------  2 frank frank  4096 Nov 22 06:01 .ssh

Couple of quick notes about my set up:

1) nonstandard ssh port 2) no password logins

  • What do the logs on your server say about the login ?
    – user9517
    Nov 22, 2017 at 6:32
  • that did it. The error was bad ownership or modes for directory so I chmoded it. If you want to write it up I'll mark you answer Nov 22, 2017 at 6:57

2 Answers 2


In cases like this it is often easier to diagnose the issue by looking in the server's logs, rather than attempting to fiugre stuff out from the client side.

  • I'm on centOS so tailed /var/log/secure and got bad ownership or modes for directory turns out rsync had changed the permissions fo my home directory. Nov 22, 2017 at 14:15

Note that either there is a protective feature or a bug with Rsync when transferring using -a into the root folder.

Given a local folder call Music containing cow.txt

rsync -a Music/ [email protected]:/usr/ 

moves the cow.txt file in the music folder in to usr/ and I can still log in.

rsync -a Music/ [email protected]:/root/ 

moves the cow.txt file into /root/ and the authorized keys are not affected but I cannot log in subsequently with [email protected].

I'm not sure why this happens and couldn't see anything in the log on the server that would explain it.

But at least it's easy to avoid the issue

Both the remote and local server and running rsync version 3.1.1 protocol version 31

on Ubuntu 16.04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .