SSH config reader.
npm i ssh2-config
const sshConfig = require('ssh2-config');
const { Client } = require('ssh2');
sshConfig({ host: 'example.com', preferSsh2: true }, (err, result) => {
const c = new Client();
c.connect(result);
});
options.host
- A string of the host name to read the setting.
options.commandLineOptions
- An array of options equivalent to
-o
ofssh
command.
- An array of options equivalent to
options.userSpecificFile
- A path of the configuration file to be read.
options.result
- The result that was read previously.
options.preferSsh2
- A boolean value as to whether to return the result corresponding to
ssh2
package.
- A boolean value as to whether to return the result corresponding to
callback(err, result)
- A callback called when setting loading is completed, or when an error occurs.
The result
argument of callback
changes properties of the object by options.preferSsh2
.
If options.preferSsh2
is truthy, the result
has the following properties:
host
port
username
privateKey
Synchronous version of sshConfig
.
MIT