How do I create alias for AWS or create SSH config file for connecting Amazon using SSH?
I'm trying to create an alias in order to SSH to an Amazon AWS EC2 Instance in an easy and faster way. I have tried:
alias amazon="ssh -o IdentityFile=~/home/user/Desktop/AWS Machines/file.pem dns.compute.amazonaws.com"
But I keep getting:
ssh: Could not resolve hostname machines/file.pem: Name or service not known
How do I create that successfully?
An appropriate ~/.ssh/config
entry might be:
Host amazon
Hostname your_ec2_instance.compute.amazonaws.com
IdentityFile "/home/your_user/Desktop/AWS Machines/private_key.pem"
You should then be able to connect simply using:
ssh amazon
This path has spaces and you are using a relative path, it is recommended to use an absolute path:
IdentityFile=~/home/user/Desktop/AWS Machines/file.pem
The correct way should be:
IdentityFile="/home/user/Desktop/AWS Machines/file.pem"
In case you want to use a relative path, this symbol ~
points to /home/your_current_user
, so the path will be:
IdentityFile="~/Desktop/AWS Machines/file.pem"