1

I seem to be having a little issue with connecting to a remote server, to rsync my backups

what i have done so far

run ssh-keygen created public and private key

run ssh-copy-id -i my.key.pub 100.0.0.01

it all connected ok, i even went to remote server and checked .ssh/authorized_key and confirmed the key was there

but when i run ssh 100.0.0.01 it still asks for a password, plus when i run a cron job to rsync it fails with permission denied.

Does anybody have any ideas as to why it wont connect?

cas
  • 78,579
  • If you're running SElinux, you may need to run restorecon -R -v ~/.ssh – Matt Mar 25 '16 at 17:13
  • Are you certain you're running ssh with the correct user name for the remote server? – Dan Getz Mar 25 '16 at 20:11
  • hi , yes, when i access through ssh i can connect, but it keeps asking me for the pasword, when i apply the password i can conect – user2513528 Mar 25 '16 at 20:20
  • 3
    Your use of my.key.pub on ssh-copy-id suggests you named your privatekey file my.key not the ssh-keygen default .ssh/id_rsa (or dsa or whatever). If so, that file won't be used. You must either (1) put the file in .ssh with the default name; (2) specify -i my.key on ssh and -e 'ssh -i my.key' on rsync, plus path if not in the same dir; or (3) create or edit .ssh/config to specify it. And in all cases it must be accessible only by your id. @roaima #269452 is for a ppk file generated by PuTTY, clearly not the case for this Q. – dave_thompson_085 Mar 25 '16 at 21:01
  • @dave_Thompson_085 the permissions aspect is potentially equally relevant, although I like your suggested diagnosis here – Chris Davies Mar 25 '16 at 21:05
  • hi, i carried out your suggestions, and it worked, i changed the file name to default id_rca.pub, and it connected fine, thank you so much for your help – user2513528 Mar 25 '16 at 22:56
  • @roaima #269452 contains nothing about permissions, although #36540 (linked in comment by DanGetz on answer) does. – dave_thompson_085 Mar 26 '16 at 01:25

3 Answers3

2
  • Check permissions of ~/.ssh folder and its content in client and server machine.
  • Check /etc/ssh/ssd_config in the server to ensure that RSAAuthentication, PubkeyAuthentication and UsePAM options aren't disabled, as they are enabled by default with yes.
  • If you entered a passphrase while generating your client key, then you may try ssh-agent & ssh-add to achieve password-less connections in your session.
  • Check the contents of /var/log/auth.log on the server to find the issue why key authentication is skipped at all.
marc
  • 2,427
0

Three things to think about:

1) Is the remote host configured to allow key authentication? (See man sshd_config AuthenticationMethods and PubkeyAuthentication)

2) Is the cron job scheduled to run under the right user context ( root vs. other user )

3) Do you have permission on the remote host to the target directory.

Lambert
  • 12,680
-3
cd
ssh-keygen 
cp .ssh/id_rsa.pub .ssh/authorized-keys
ssh-copy-id -i .ssh/id_rsa.pub 100.0.0.1
Archemar
  • 31,554
al mamun
  • 123
  • -1 for two reasons. (a) there's no explanation of what this does or what you intend it to do, (b) the asker explained they'd already done this but it hadn't worked for them. – Chris Davies Mar 25 '16 at 19:50
  • This is a response to the question's title, not the question itself. – Dan Getz Mar 25 '16 at 20:21