# ssh-keygen -t rsa -b 4096 -C "root@localhost"
Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 33:4c:b1:a1:b0:f7:3a:85:0c:85:b9:6b:eb:c6:69:8b root@localhost The key's randomart image is: +--[ RSA 4096]----+ | .o. o | | o+ . + | | o.o o | | .+ = | | .o S | | o o o | | o oo | | .* . | | E+o. | +-----------------+
# ls -l .ssh/
total 8 -rw-------. 1 root root 3239 Aug 13 13:11 id_rsa -rw-r--r--. 1 root root 736 Aug 13 13:11 id_rsa.pubOnce the the public key is generated, copy the .pub file as authorized_keys under .ssh directory under user home for the user in destination server. Once done, try to do ssh which will connect without password
# cat .ssh/id_rsa.pub | ssh root@server2 'cat >> .ssh/authorized_keys'
# scp test_file.txt root@server2:/tmp/test_file.txt 100% 20 0.0KB/s 00:00