Lejdborg/NMSSH — pull request #82 by gnachman (2014-05-09 20:50:14+00:00)
Title: Add NMSSHConfig, which parses ssh config files. Also add tests for it.

Users often have a ~/.ssh/config file which can specify (among other things) a mapping between a nickname for a host and the actual hostname and port number, plus which identity file to use.

This change adds a parser for the config file. It's based on the code in libssh (not libssh2, which sadly does not have such a parser). Currently, only the Host, Port, and IdentityFile keywords are supported. This is enough to solve a lot of problems, though.

NMSSHConfig is a new class which can read in and parse the config file. Each entry becomes an NMSSHHostConfig object. NMSSHConfig also provides an interface for searching the set of entries for one matching a user-provided host name.

As it stands, this code does not hook into NMSSHSession; it is entirely up to the client application to translate a user-provided hostname into a config-specified hostname, port, and identity. In the future, an extra initializer could be added to NMSSHSession like "initWithHost:config:defaults:" (where "defaults" provides default values for port, username, etc., if not given in the config file, plus substitutions such as the local home directory).