Create a ~/.ssh/config
and open it in the editor. Write like following
Host remote_server
Hostname [remote server name or IP address or DNS name]
User [remote username]
Port [port number]
IdentityFile [local path to private key file]
Replace [remote server name or IP address]
with the actual name or IP address of the remote system, [remote username]
with the actual username on the remote system, and [local path to private key file]
with the actual path to the private key file on your local system, and [Port]
with your server’s ssh port number, you can find it from security groups in EC2 dashboard (sidebar). Save the file and close the editor.
Now, you will need to write protected
the .pem
file. To do that run the following command on your terminal.
chmod 400 my_production_server.pem
Open the terminal and type ssh remote_server
. If your configuration is correct then it will connect the server.
Example for AWS EC2 instance connection through key pair:
Host my_production_server
Hostname 12.567.0.1 #this is not valid IP
User root
Port 22
IdentityFile /home/user/app/keys/my_production_server.pem
It’s help me to solve my problem, thanks.