Class Net::SSH::Config
In: lib/net/ssh/config.rb
Parent: Object

The Net::SSH::Config class is used to parse OpenSSH configuration files, and translates that syntax into the configuration syntax that Net::SSH understands. This lets Net::SSH scripts read their configuration (to some extent) from OpenSSH configuration files (~/.ssh/config, /etc/ssh_config, and so forth).

Only a subset of OpenSSH configuration options are understood:

  • Ciphers => maps to the :encryption option
  • Compression => :compression
  • CompressionLevel => :compression_level
  • ConnectTimeout => maps to the :timeout option
  • ForwardAgent => :forward_agent
  • GlobalKnownHostsFile => :global_known_hosts_file
  • HostBasedAuthentication => maps to the :auth_methods option
  • HostKeyAlgorithms => maps to :host_key option
  • HostKeyAlias => :host_key_alias
  • HostName => :host_name
  • IdentityFile => maps to the :keys option
  • Macs => maps to the :hmac option
  • PasswordAuthentication => maps to the :auth_methods option
  • Port => :port
  • PreferredAuthentications => maps to the :auth_methods option
  • ProxyCommand => maps to the :proxy option
  • RekeyLimit => :rekey_limit
  • User => :user
  • UserKnownHostsFile => :user_known_hosts_file

Note that you will never need to use this class directly—you can control whether the OpenSSH configuration files are read by passing the :config option to Net::SSH.start. (They are, by default.)

Methods

default_files   for   load   translate  

Public Class methods

Returns an array of locations of OpenSSH configuration files to parse by default.

Loads the configuration data for the given host from all of the given files (defaulting to the list of files returned by default_files), translates the resulting hash into the options recognized by Net::SSH, and returns them.

Load the OpenSSH configuration settings in the given file for the given host. If settings is given, the options are merged into that hash, with existing values taking precedence over newly parsed ones. Returns a hash containing the OpenSSH options. (See translate for how to convert the OpenSSH options into Net::SSH options.)

Given a hash of OpenSSH configuration options, converts them into a hash of Net::SSH options. Unrecognized options are ignored. The settings hash must have Strings for keys, all downcased, and the returned hash will have Symbols for keys.

[Validate]