ssh using pem file

How to SSH using pem File in Ubuntu Terminal

Often you may need to connect to your SSH server from Ubuntu. But sometimes you may have a .pem key file as private key. This is true if you need to connect to EC2 instance from Ubuntu, since Amazon gives you a .pem file. In this article, we will look at how to SSH using pem file in Ubuntu terminal.


How to SSH using pem File in Ubuntu Terminal

Here are the steps to SSH using pem file in Ubuntu terminal.


1. Go to Folder with pem key

Open terminal and go to the folder with your pem key file. We have assumed that our pem key file is located at /downloads folder.

$ cd /downloads


2. SSH using pem file

You can easily ssh from this folder with the following command. Replace file.pem with the filename of your pem file, ip-address with the IP address of your SSH server, and username with the SSH username.

$ sudo ssh -i file.pem username@ip-address 

Once you enter the above command, you will be asked to confirm if you want to add the host to your list of known hosts. Type yes and press enter key. If you enter yes, then this prompt will not appear the next time you SSH into remote server. Else it will appear every time you try to connect.

After you enter yes, you will automatically be connected to SSH server.

That’s it. You have successfully logged into SSH.

In this article, we have learnt how to log into SSH server using pem key file.

Also read:

SCP Command to Copy Files & Folders
How to Read YAML File to Dict in Python
How to Delete Empty Lines from Text File in Linux
How to Install Supervisor in RHEL/CentOS/Fedora
How to Install OpenSSL in Ubuntu

Leave a Reply

Your email address will not be published.