# SSH config files

## Why use ssh config files?
SSH config files are nice to have when you need to connect to multiple servers and don't wanna type the entire an entire server address and username. For example: instead of `ssh user@serveradress.co` you can type `ssh hostname` and that saves some brainpower for the rest of the fabacademy!

## What can you do with ssh config files
In SSH config files you can describe how connections should be handled and with which keys you want to use to log in onto a specific server and much more.

## How is a config file structured
```config
Host hostname1
    SSH_OPTION value
    SSH_OPTION value

Host hostname2
    SSH_OPTION value

Host *
    SSH_OPTION value
```
A entry always start with `Host` and then the name you wanna give to that host. After that you press enter and then tab. Now you can define the options for the ssh connections.

Example:
```config
HOST gitwaag
        Hostname gitlab.waag.org
        User git
        IdentityFile ~/.ssh/id_ed25519
        IdentitiesOnly yes
```
In this config I defined the host as gitwaag. So I can connect to it using the command ```ssh gitwaag``` instead of ```ssh gitlab.waag.org```.

#### Explanation of the parameters used in this config above
* `Hostname` Defines the hostname/domain of the server
* `User` The username you wanna log in as on the server
* `IdentityFile` Which public key you want to use for the connection
* `IdentitiesOnly` Set it to only use the IdentityFile instead of other authentication files.

For a full list of parameters you can visit https://phoenixnap.com/kb/ssh-config or run `man ssh_config` in the terminal.


## Sources:
* https://linuxize.com/post/using-the-ssh-config-file/
* https://phoenixnap.com/kb/ssh-config
