How to ssh without password,
there is time when we want to automate process like transfer file between our server or sending command to remote server. to be able to make cronjob do the job easily we will need to ssh without password to remote server.
first you need to create ssh pub key of your server or if you can check first if its existed on you server
cd ~ cd .ssh ls
in my server this is the result for above command
[admin@servergue ~]$ cd ~
[admin@servergue ~]$ cd .ssh
[admin@servergue .ssh]$ ls
id_rsa id_rsa.pub known_hosts
if files above don’t exist you need to create one using below command
ssh-keygen -t rsa
[admin@servergue ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/admin/.ssh/id_rsa):
Created directory ‘/home/admin/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/admin/.ssh/id_rsa.
Your public key has been saved in /home/admin/.ssh/id_rsa.pub.
The key fingerprint is:
The key’s randomart image is:
+–[ RSA 2048]—-+
| .E+ |
| . +=o+ |
| + o.** .|
| S + o .B |
| . . o|
| . |
now check directory .ssh
cd .ssh ls
file id_rsa id_rsa.pub known_hosts should appear there.
Now what you need to do is to copy what inside id_rsa.pub to your remote server.
[admin@servergue ~] cat .ssh/id_rsa.pub | ssh apps@remoteserver 'cat >> .ssh/authorized_keys' apps@remoteserver's password:
enter the password for your remote server.
Now you should be able to ssh without password to remote server..
*change username and hostname with your own username and server ip address
server 1 = admin@servergue ==> (username@ipaddress)
remoteserver = apps@remoteserver ==> (username@remoteserver’sipaddress)