SSH config file

The ssh config file is typically in your home directory: ~/.ssh/config

Adding options to this file can simplify your ssh usage, so you don’t have to remember which username and public key go with each computer.

Here’s an example ~/.ssh/config file, with an explanation of each line below.

#
# ssh config file
#
Host *
  ForwardAgent yes
  ForwardX11 yes
  ServerAliveInterval 30
  IdentityFile ~/.ssh/id_ed25519
#
# 
Host sccs
    User csmajor1
    Hostname sccs.swarthmore.edu

Host syrup
    User donaldduck
    Hostname syrup.cs.swarthmore.edu
    Port 2222
    ForwardX11 no

Host rad
    Hostname horseradish.cs.swarthmore.edu

The first “stanza” (the Host * line plus the 4 indented lines) applies to all hosts, unless an option is specified again later for a specific host. These initial “catch all” options include:

The next few stanzas allow me to specify:

Using the above I can type ssh sccs instead of ssh csmajor1@sccs.swarthmore.edu, ssh syrup instead of ssh -p 2222 -Y donaldduck@syrup.cs.swarthmore.edu, and ssh rad instead of ssh horseradish.cs.swarthmore.edu.


See also:


Back to SwatCS Help Docs