Some of my colleagues asking me this, how can i login to my server using certificate like i login to aws (amazon web services).
1. Setup your server
firstname.lastname@example.org# ssh-keygen -t rsa -b 2048
email@example.com# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
2. Copy your secrets to your a file let’s give it a name ‘awan.access.pem’, you can give it any name you want
awan@local_machine.dev.google.com# scp firstname.lastname@example.org:~/.ssh/id_rsa .
awan@local_machine.dev.google.com# cp id_rsa awan.access.pem
awan@local_machine.dev.google.com# chmod 0600 awan.access.pem
or just cat the id_rsa file, copy the content to a file and rename the file
3. Let’s access our box using .pem certificate file from any box, please don’t share the key to unauthorized personel
awan@local_machine.dev.google.com# ssh -i awan.access.pem email@example.com
awan : change is to your username
google.com : this is also an example, change this to your server ip, linux box, or your domain name
after step number 2 your can create image or snapshot from the virtual machine or container so next time you login you don’t have to regenerate the key anymore.