Posted on Aprile 2, 2017
The magic of ~/.ssh/config
Hi, today I want to talk about the ~/.ssh/config file.
First thing about this magic file: if you are using ssh you must have this file, this is a fact.
For example, i use git with ssh, because ssh is a very good protocol, and to use git over ssh we don’t use the TTY, so we can put in the config file something like:
Host git.kde.org User git RequestTTY no
In this way I can execute
without seeing the annoing “PTY allocation request failed” message.
Another sorcery happens when you have multiple ssh keys, I have one key for each “scope”, for example: one for KDE, one for GitHub, one for GitLab, one for my home, ecc.
I don’t want to use the “-i” option each time to select the right key, this is why I use the IdentityFile option, for example applyed to “*.kde.org”.
Sometime I have to connect to a server without direct access to the sshd daemon with a direct TCP connection, in this scenario i use the “ProxyCommand” option, this is a command to execute to proxy the ssh connection via another host, for example “ProxyCommand ssh bastion.<domain> nc %h %p”.
The last useful thing is that you can create an alias for an host, for example I have my server with FQDN “srv.domain.tdl” listening on port 1900 TCP, I can create an alias, like “srv” using something as:
Host srv HostName srv.domain.tdl Port 1900
With this config I can run “ssh srv” and be on my server.
Thanks for reading.