0

I created a ssh-key to log into my CentOS VPS, altered the default port to 2020 and disabled password connection, so I can only log in this VPS using the key (that need a password to be unlocked). My machine runs Ubuntu 16.04.

I logged in the server and, as usual for the first log, it asked my ssh-key password. I prompted, everything ok. Made some tests, and them I tried, for the first time, to use rsync to transfer files to VPS's web server. I had open a new terminal window and issued the command:

rsync -azP -e "ssh -p 2020" /var/www/html/myfolder myuser@myhost:/var/www/html

The first time it outputed:

The authenticity of host '[myhost]:2020 ([myhost]:2020)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxx

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '[myhost]:2020' (RSA) to the list of known hosts.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]

I think it's strange. Why it had to add my key again? And why rsync couldn't connect? When I try now I receive the same connection denied message (not the key add message anymore). Can someone put a light on it?

UPDATE:

Command I use to log into the server:

ssh myuser@myhost -p 2020

If it is the first connection, it asks for ssh-key password.

VPS /etc/ssh/sshd_config (without comments):

Port 2020
Protocol 2
SyslogFacility AUTHPRIV
PermitRootLogin yes
PasswordAuthentication no
AllowUsers myuser root
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding no
Subsystem       sftp    /usr/libexec/openssh/sftp-server

If I'm running both users with the same user:

I didn't understand this question... =\

Where are the keys?

Well, I'm a newbie in ssh, I just had generated the keys with the command ssh-keygen, so I'm pretty sure the keys were in the default folders. And they're working, because I can connect with the VPS.

-VVV mode:

sudo rsync -aPvvv -e "ssh -p 2020" /var/www/html/curriculum/ myuser@myhost:/var/www/html

opening connection using: ssh -p 2020 -l myuser myhost rsync --server -vvvlogDtpre.iLsfx --partial . /var/www/html  (12 args)
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
[sender] _exit_cleanup(code=12, file=io.c, line=226): about to call exit(255)
  • post the command you are using to connect to the server. Also potential ~/.ssh/config. Are you running both users under the same user? Where is the key you are using for authentication? What do you get with -vvv switches to ssh in rsync command? – Jakuje May 7 '16 at 21:22
  • Updated with the info you asked :) – André Carvalho May 7 '16 at 21:56
  • You are running the rsync command under sudo, therefore under different user, who can not find your authentication key. – Jakuje May 8 '16 at 7:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.