/ mozey.co / blog

ssh using key file

July 1, 2013

Sometimes we have to use a private key to ssh to a server. This is the default method of access to Amazon EC2 instances. The private key is generated and must be downloaded when the new instance is created.

The key file must be kept secret! Anyone who has a copy of this file can gain access to the server.

The key file can be passed to ssh

ssh -i /path/to/key.pem [email protected]

We could also install the key file in order to ssh without having to pass it as an option, Install the key file by mapping it to the IP address/Domain name of the server

sudo vi ~/.ssh/config

Host xxx.xxx.xxx.xxx User USERNAME IdentityFile /PATH/TO/KEY.PEM