User Tools

Site Tools


the_ssh_config

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

the_ssh_config [2021/06/22 17:29] – created 134.190.232.18the_ssh_config [2021/06/22 17:34] (current) 134.190.232.18
Line 12: Line 12:
 To type this out every time you want to start a new SSH session with a particular host can be quite a pain! To type this out every time you want to start a new SSH session with a particular host can be quite a pain!
  
-A smarter way would be to make use of the so-called **SSH Config** file. In this file, located at ''~/.ssh/config'' you can specify per host which flags you want to invoke by default when SSHing into that host.+A smarter way would be to make use of the so-called **SSH Config** file. In this file, located at ''~/.ssh/config'' you can specify per host which flags you want to invoke by default when SSHing into that host. If that file doesn't exist on your system, you can simply create it.
  
 For example, let's say your SSH config file includes For example, let's say your SSH config file includes
Line 36: Line 36:
 </code> </code>
  
 +As you can see this can save a lot of keystrokes in the long run!
  
 +To save even more keystrokes, you can add the following code in your ''.bashrc''
 +
 +<code>
 +# add tab completion for remote hosts in ssh config file 
 +complete -o default -o nospace -W "$(grep '^Host' ~/.ssh/config | cut -d' ' -f2)" ssh
 +</code>
 +
 +This will add all the host aliases in your SSH config file to the tab-complete list. This means that you can type ''ssh p'', then hit ''Tab'', and it will autocomplete to ''ssh perun''. (provided no other defined hosts in the SSH Config file start with p)
the_ssh_config.1624393766.txt.gz · Last modified: by 134.190.232.18