Koozali.org: home of the SME Server

Rsync and Passwordless ssh Login

Offline Bud

  • *
  • 487
  • +0/-0
Rsync and Passwordless ssh Login
« on: June 15, 2018, 07:18:02 AM »
guys please can you help

i have the following scenario

CentOS 7 Server A
SME 9.2 Server B

I do the following on the SME 9.2 Server B
# ssh-keygen -t rsa
The Following Two Keys ( files ) are created in /root/.ssh
1. id_rsa
2. id_rsa.pub


I change the permission on the id_rsa.pub file of the SME 9.2 Server B
# chmod 600 /root/.ssh/id_rsa.pub

I am still on the SME 9.2 Server B shell and copy the created id_rsa.pub file to CentOS 7 Server A
# scp /root/.ssh/id_rsa.pub  root@centos7IP:/root/id_rsa.pub

I login to the CentOS 7 Server A
# touch /root/.ssh/authorized_keys
# chmod 600 /root/.ssh/authorized_keys


Now i attach the public key generated in the SME 9.2 Server B to the “ authorized_keys “ file on the CentOS 7 Server A
# cat /root/id_rsa.pub >> /root/.ssh/authorized_keys

I log back into the SME 9.2 Server B
When i do the following
# ssh root@centos7IP  - LOGIN WITHOUT PASSWORD REQUEST WORKS

Here is my question
When i do the Following from the SME 9.2 Server B
# /usr/bin/rsync -avz -e "ssh -i /root/.ssh/id_rsa.pub"  root@CentOS7IP:/home   /var/ServerBackup

I get the following problems on the  SME 9.2 Server B
Enter passphrase for key '/root/.ssh/id_rsa.pub':
AND
root@CentOS7IP's password:

Please guys what do i need to do to run the script " # /usr/bin/rsync -avz -e "ssh -i /root/.ssh/id_rsa.pub"  root@CentOS7IP:/home   /var/ServerBackup " without it asking me for passwords ?

Any help greatly appreciated  :-)


« Last Edit: June 15, 2018, 10:12:30 AM by Bud »

Offline ReetP

  • *
  • 3,722
  • +5/-0
Re: Rsync and Passwordless ssh Login
« Reply #1 on: June 15, 2018, 10:53:23 AM »
Haven't you already asked all this on your other thread ??

https://forums.contribs.org/index.php/topic,53572.45.html

Quote
I change the permission on the id_rsa.pub file of the SME 9.2 Server B
# chmod 600 /root/.ssh/id_rsa.pub

Why ? Don't touch it.

Code: [Select]
I get the following problems on the  SME 9.2 Server B
Enter passphrase for key '/root/.ssh/id_rsa.pub':
AND
root@CentOS7IP's password:

Probably because you set a password on your SME key.

Please go back, read the stuff on your other thread. And read the wiki where surprisingly there are notes:

https://wiki.contribs.org/SSH_Public-Private_Keys
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Bud

  • *
  • 487
  • +0/-0
Re: Rsync and Passwordless ssh Login
« Reply #2 on: June 15, 2018, 01:13:16 PM »
ReetP thank you for your help

yes you are correct, however i am getting confused due to the fact when i issue the command: " # ssh root@centos7IP "
everything works perfectly. No questions for passwords etc. It just works

However when i do: # /usr/bin/rsync -avz -e "ssh -i /root/.ssh/id_rsa.pub"  root@CentOS7IP:/home   /var/ServerBackup "
it styarts asking for passwords.

what am i missing  :-)

Offline ReetP

  • *
  • 3,722
  • +5/-0
Re: Rsync and Passwordless ssh Login
« Reply #3 on: June 15, 2018, 01:24:52 PM »
You really ought to RTFM

https://linux.die.net/man/1/rsync

Why do you need -e ?

"If you need to specify a different remote-shell user, keep in mind that the user@ prefix in front of the host is specifying the rsync-user value (for a module that requires user-based authentication). This means that you must give the '-l user' option to ssh when specifying the remote-shell, as in this example that uses the short version of the --rsh option:

rsync -av -e "ssh -l ssh-user" rsync-user@host::module /dest"

I'm not sure you want to be doing that.....
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Jean-Philippe Pialasse

  • *
  • 2,743
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Rsync and Passwordless ssh Login
« Reply #4 on: June 15, 2018, 02:12:06 PM »
The issue is you need to point to the private key not the public in your rsync ssh syntax.


id_rsa not id_rsa.pub


When you did ssh you did not precise the key and it default to id_rsa. The principle of private and public key is the same as hardware key and hardware lock. You use the key to open athe lock, not a lock to open the same lock....

So you send your lock to the other server so it could be on the front door, then you use your personal key id_rsa to open you known lock id_rsa.pub