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:
ForwardAgent – whether to forward the ssh-agent connection to the remote computer (i.e., if I am using ssh-agent, and I ssh to a remote computer (without having to type my passphrase), I can keep going and ssh from there to another remote computer and still not have to type my passphrase)ForwardX11 – whether to forward the X11 connection to the remote computer (i.e., if I ssh to a remote computer and run a program that pops up a graphical window, should that window show up on my local computer)ServerAliveInterval – how many seconds to wait for a response from the server (useful if your idle ssh sessions are being dropped or terminated)IdentityFile – which ssh public key to use (you can have more than one ssh key)The next few stanzas allow me to specify:
User)Host and Hostname)ForwardX11 no for syrup)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: