This is very helpful for me at least, every time I was connecting to Amazon's AWS I need to do something like below
ssh -i key.pem ubuntu@abc.compute.amazonaws.com
To run every time I have to remember the hostName, where is my key.pem file.
To avoid all above, one way to edit ~/.ssh/config file.
So I want something below to connect to aws instance.
ssh awshost
To work above I did something below
mkdir -p ~/.ssh
cp ~/Downloads/key.pem ~/.ssh/
chmod 400 ~/.ssh/key.pem
chmod 700 ~/.ssh
After this edit ~/.ssh/config file, add following entry to config file
Host awshost
HostName abc.compute.amazonaws.com
User ubuntu
IdentityFile "~/.ssh/key.pem"
Save the file.
After doing this
ssh awshost
should connect to AWS instance.
Example of above how it is useful.
scp hello.tx awshost:~/
ssh -i key.pem ubuntu@abc.compute.amazonaws.com
To run every time I have to remember the hostName, where is my key.pem file.
To avoid all above, one way to edit ~/.ssh/config file.
So I want something below to connect to aws instance.
ssh awshost
To work above I did something below
mkdir -p ~/.ssh
cp ~/Downloads/key.pem ~/.ssh/
chmod 400 ~/.ssh/key.pem
chmod 700 ~/.ssh
After this edit ~/.ssh/config file, add following entry to config file
Host awshost
HostName abc.compute.amazonaws.com
User ubuntu
IdentityFile "~/.ssh/key.pem"
Save the file.
After doing this
ssh awshost
should connect to AWS instance.
Example of above how it is useful.
- Copy file from/to remote instance
scp -i key.pem hello.txt ubuntu@abc.compute.amazonaws.com:~/
scp hello.tx awshost:~/