Antonio Pitasi

A personal space for personal thoughts

SSH

Tuning SSH Config #

I’m going to outline a couple must configurations I use in my ~/.ssh/config:

  1. Automatically close connections on network failures:

    
    ServerAliveInterval 5
    ServerAliveCountMax 1
    
    

    This way SSH send an echo (a sort of ping) every 5 seconds, if didn’t get a reply for “1” times it closes the connection.

    But if you’re stuck in a session for some reason, you can always just press the following keys in order: <Enter>~..

  2. Set up usernames so you don’t have to type ssh username@company.com all the time, but just ssh company.com:

    
    Host company.com
        User antonio
    
    # works with wildcards too
    Host *.company.com
        User antonio
    
    

    just remember that rules are applied in order, so the first match wins. Run ssh -v company.com and you’ll see something like debug1: /home/antonio/.ssh/config line 4: Applying options for company.com.