As long as I’ve been using SSH, I only recently started using SSH Config.
I have many Linux computers (Raspberry Pis, desktops and laptops) on my local network. It’s difficult to remember each computer’s IP address and username when using SSH. SSH Config allows you to define ssh connection options in one location. Note: SSH Config is available on Mac and Linux when using OpenSSH Client.
Given the following ~/.ssh/config file:
Host pi3b HostName 192.168.1.245 User pi Host pizerow HostName 192.168.1.210 User pi
The SSH command
ssh firstname.lastname@example.org is replaced with
ssh pi3b .
Below is a list of common options used in ~./ssh/config. A full list of config option are available at ssh.com.
HostName – IP address or URI to a remote computer
User – SSH username
Port – SSH port different than the default 22
IdentityFile – Specify a specific key file
ForwardAgent – (no/yes) Allow SSH server access to client SSH Agent for sharing SSH keys
Host stephencross HostName ssh.stephencross.com User sshuser Port 2222 IdentityFile ~/.ssh/stephencross.pub
SSH options are used for all Hosts that match from top down in the config file. Given the follow ~/.ssh/config file:
Host pi3b HostName 192.168.1.245 Host pizerow HostName 192.168.1.210 Host picm4 HostName 192.168.1.234 Host pihole HostName 192.168.1.134 User piadmin Host nuc HostName 192.168.1.196 User stephencross Host pi* User pi Host * !nuc Compression yes
Host pi*– User is set to ‘pi’ for all Hosts that begin with ‘pi’. Because
Host piholehas User define higher in the file, it’s user name is ‘piadmin’
Host * !nuc– Compress is ‘on’ for all Hosts, except Nuc
SSH Config is easy to setup and a big time saver.