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
Related posts:
Shell Script to Remove Last N Characters from String
cURL Command to Call REST API
How to Split File in Linux
How to Deny SSH Access to Users or Groups
How to Export PostgreSQL Table to CSV
How to Record & Replay Terminal Session in Linux
How to Empty or Delete Contents of Large File in Linux
How to Keep SSH Session Alive After Disconnect in Linux
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.