Koozali.org: home of the SME Server
Contribs.org Forums => General Discussion => Topic started by: Bud 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 :-)
-
Haven't you already asked all this on your other thread ??
https://forums.contribs.org/index.php/topic,53572.45.html
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.
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
-
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 :-)
-
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.....
-
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