How to create pem file and access linux Server via pem file
How to create pem file and access linux Server via pem file
In this tutorial we setup pem file to login server(Ubuntu) with pem file without password on linux server. We are create pem file which used to access linux server. Pem file is a private file which do generate via ssh-keygen on linux server.
Impotent :- You need to backup old key files if you have old keys server.
1st create the keys and RSA will create public and private keys. if you no need add passphrase on your key then you can add passphrase with key but I skipped the passphrase on server.
[root@solutionclub ~]# ssh-keygen -t rsa -b 2048 Enter file in which to save the key (/home/solutionclub/.ssh/id_rsa): Enter Created directory '/home/solutionclub/.ssh'. Enter passphrase (empty for no passphrase): Enter Enter same passphrase again: Enter Your identification has been saved in /home/solutionclub/.ssh/id_rsa. Your public key has been saved in /home/solutionclub/.ssh/id_rsa.pub. The key fingerprint is: 58:33:80:a5:df:14:b1:af:4f:90:07:35:3x:01:50:02
Now we are creating private to pem key
[root@solutionclub ~]# openssl rsa -in /home/solutionclub/.ssh/id_rsa -outform pem > /home/solutionclub/solutionclub.pem
We need to generate the public key PEM file for users distribution :
[root@solutionclub ~]# openssl rsa -in solutionclub.pem -pubout -out pub_dsa.pem
After generating pem from id_rsa (Private Key) then we need to set file permission on pem file.
[root@solutionclub ~]# chmod 600 /home/solutionclub/solutionclub.pem
Now you need to copy pem key to your server which your are need to password less authenticate.
[root@solutionclub ~]# mkdir ~/.ssh [root@solutionclub ~]# cat solutionclub.pem >> .ssh/authorized_keys [root@solutionclub ~]# chmod 600 .ssh/authorized_keys
After these steps you need to add change some parameters in sshd_config file.
[root@solutionclub ~]# vim /etc/ssh/sshd_config RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile %h/.ssh/authorized_keys PasswordAuthentication no # Change to no to disable s/key passwords ChallengeResponseAuthentication no UsePAM yes
After save file then you can check your connection on terminal
[root@solutionclub ~]# ssh -i /home/solutionclub/solutionclub.pem test@
That should do it! I hope you find this tutorial helpful. Feel free to ask any questions!