SSH access and SCP move files between Centos servers

Move file from centos-server1 to centos-server2

1. Generate Key pair for ssh access on server2
[centos@jump .ssh]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/centos/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/centos/.ssh/id_rsa.
Your public key has been saved in /home/centos/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:MHUSRaPKFTk1RB07MGgHXmcpg2N48AD3crfIIIIeP6Y centos@jump.novalocal
The key’s randomart image is:
+—[RSA 2048]—-+
| ..+o*%&.+o |
| . ..*X*+Bo. |
|… . =+B+.oo |
|. o. o X o . . |
| . + o S . |
| o . |
| E |
| |
| |
+—-[SHA256]—–+
[centos@jump .ssh]$ ls -all
total 16
drwx——. 2 centos centos 80 Sep 27 01:38 .
drwx——. 4 centos centos 167 Sep 26 22:38 ..
-rw——-. 1 centos centos 402 Sep 18 21:08 authorized_keys
-rw——-. 1 centos centos 1679 Sep 27 01:38 id_rsa
-rw-r–r–. 1 centos centos 403 Sep 27 01:38 id_rsa.pub
-rw-r–r–. 1 centos centos 173 Sep 27 01:20 known_hosts

2. move id_rsa.pub from server2 to server1
WinSCP id_rsa.pub -> windows -> server1 home account
$cat id_rsa.pub >> /home/centos/.ssh/authorized_keys

3. move folder from server1 to server2
# -r for folder copy included
$scp -r centos@192.168.1.7:/home/centos/* .

 

Reference

1. How to create password less centos clusters:

https://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/

2. How To Set Up SSH Keys on CentOS 7

https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-centos7

Leave a comment