Update README.md

This commit is contained in:
Mike Peralta 2018-05-27 03:45:02 -07:00 committed by GitHub
parent 5003f3fd05
commit d748e2ae53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,7 @@ You can also try using this script with a different daemon (or your own custom s
6. Repeat steps 2-5 for each additional user who would like connection based ssh configuration files. 6. Repeat steps 2-5 for each additional user who would like connection based ssh configuration files.
## Example Scenario ## Example Scenarios
Why would you use this script? Suppose the following scenarios: Why would you use this script? Suppose the following scenarios:
@ -49,3 +49,38 @@ Why would you use this script? Suppose the following scenarios:
* You have several servers which you can connect directly to from work. Your work has no VPN, so when at home, these servers aren't exactly online; You must first connect to a gateway server on your employer's network, then use that gateway server as a proxy to reach the other internal servers. This is generally called Transparent Multihop over SSH ([example](http://sshmenu.sourceforge.net/articles/transparent-mulithop.html)). Thus, it would really be convenient to have one ssh configuration file for home, and one for work. * You have several servers which you can connect directly to from work. Your work has no VPN, so when at home, these servers aren't exactly online; You must first connect to a gateway server on your employer's network, then use that gateway server as a proxy to reach the other internal servers. This is generally called Transparent Multihop over SSH ([example](http://sshmenu.sourceforge.net/articles/transparent-mulithop.html)). Thus, it would really be convenient to have one ssh configuration file for home, and one for work.
Each of these scenarios can be solved by the connection-specific-ssh-config script. Simply create as many ssh configuration files as you need, and each can be dynamically symlinked as you connec to different networks.
## Configuration File
Configuration files for connection-specific-ssh-config are just standard python/php style ini files, and are relatively simple:
* You need a section called "config", which currently only holds one variable:
* *ssh_dir*, which specifies the directory your ssh client looks for configuration files (typically *~/.ssh/*)
* You then need one or more sections which specify targets that associate ssh configuration files with network connection names
* The key *ssh__config_name* specifies the name of the ssh configuration file that should apply if this target activates
* You can then optionally add a "default" section, which specifies which default ssh configuration file to fallback to, if any
Here's an example configuration file to help you get started:
```
[config]
ssh_dir = /home/mike/.ssh
[default]
adapter = wlan0
ssh_config_name = config-default
[Wifi Work]
adapters = ["wlan0", "wlan1"]
ssids = ["Work Connection - Main Office", "Work Connection - Garys Office"]
ssh_config_name = config-work
[Wifi Home]
adapter = wlan0
ssid = My Home Connection (Oh Joy)
ssh_config_name = config-home
```
The above configuration file will instruct the script to use the ssh configuration file */home/mike/.ssh/config-work* while you're connected to one of your work connections *Work Connection - Main Office* or *Work Connection - Garys Office*, on either of your wireless adapters *wlan0* or *wlan1*. When you get home and connect to your *My Home Connection (Oh Joy)* connection on *wlan0*, the config file */home/mike/.ssh/config-home* will be used instead. Finally, the configuration file */home/mike/.ssh/config-default* will be used when *wlan0* connects to some undefined network.