Skip to content

Advanced SSH Configuration

macOS and Linux

Here are some tips on maintaining connections and adding tab complete to your SSH commands on Linux and macOS:

  1. Use ssh_config file to create aliases for your connections:

    Host alias_name
        HostName ogun-login.senaicimatec.com.br
        User your_username
        IdentityFile /path/to/your/private_key
    

    Replace alias_name, clustername, your_username, and /path/to/your/private_key with your desired alias, the name of the cluster you want to connect to, your username, and the path to your private key file, respectively.

  2. Save the configuration in ~/.ssh/config file.

  3. Now you can connect using the alias:

    ssh alias_name
    
  4. To enable tab completion for SSH commands, add the following line to your shell's configuration file (e.g., ~/.bashrc, ~/.zshrc):

    complete -W "$(grep '^Host' ~/.ssh/config | cut -d ' ' -f 2)" ssh
    
  5. Source your shell's configuration file:

    source ~/.bashrc
    

    or

    source ~/.zshrc
    

Now, you can type ssh and press Tab to see a list of available aliases.