Overview
Logging In
$ ssh user@example.com- And, if needed, we can specify a different port
$ ssh user@example.com -p 3307- AWS Loggin In
$ ssh -i /path/to/identity.pem user@example.comNOTE! You may need to set permissions on the .pem file so only the owner can read/write/execute it.
If you don’t aware of how to set/change Permission Check this guide
SSH Config
- If you’re anything like me, you probably log in and out of a half dozen remote servers (or these days, local virtual machines) on a daily basis.
- And if you’re even more like me, you have trouble remembering all of the various usernames, remote addresses and command line options for things like specifying a non-standard connection port.
- Here’s something really powerful.
$ vim ~/.ssh/config
Host srv001
HostName example.com
Port 2222
User MiteshShah
IdentityFile ~/.ssh/id_example
IdentitiesOnly yes
Host srv002
HostName 192.168.33.10
User root
PubkeyAuthentication no
Host aws
HostName some.address.ec2.aws.com
User ubuntu
IdentityFile ~/.ssh/aws_identity.pem
IdentitiesOnly yesLet’s cover the options used above:
HostName- The server host (domain or ipaddress)Port- The port to use when connectingUser- The username to log in withIdentityFile- The SSH key identity to use to log in with, if using SSH key accessIdentitiesOnly-Yesto specify only attempting to log in via SSH keyPubkeyAuthentication-Noto specify you wish to bypass attempting SSH key authentication
Let’s Loggin In
- No need to remember Username/IdentityFile/Port etc
$ ssh aws