SSH Tips and Tricks

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.com

NOTE! 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 yes

Let’s cover the options used above:

  • HostName - The server host (domain or ipaddress)
  • Port - The port to use when connecting
  • User - The username to log in with
  • IdentityFile - The SSH key identity to use to log in with, if using SSH key access
  • IdentitiesOnly - Yes to specify only attempting to log in via SSH key
  • PubkeyAuthentication - No to specify you wish to bypass attempting SSH key authentication

Let’s Loggin In

  • No need to remember Username/IdentityFile/Port etc
$ ssh aws


Newsletter

Get updated when I create new content.
Unsubscribe whenever. Never any spam.

Note

I'm Tama. I turn down every ad, affiliate, and sponsor request I get. I write free resources that help people. If you enjoy my content, please consider supporting what I do.

Support my work