Class: Sambot::Ssh::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/sambot/ssh/parser.rb

Constant Summary collapse

ENTRIES =
{
  'bastion': {
    username: '',
    'HostName': '146.177.10.174',
    'LocalForward': [
      '8200 vault.brighter.io:8200',
      '9997 splunk.brighter.io:9997'
    ]
  },
  'AVG-*': {
    aliases: ['avg-*', 'GD-*', 'gd-*', 'NW-*', 'nw-*', 'PHX-* phx-* RS-* rs-* THD-* thd-*'],
    username: '',
    'ProxyJump': 'bastion',
    'StrictHostKeyChecking': 'no'
  }
}

Instance Method Summary collapse

Instance Method Details

#update(username, config_file = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sambot/ssh/parser.rb', line 27

def update(username, config_file = nil)
  config = ConfigFile.new(config_file)
  ENTRIES.each_pair do |key, val|
    config.rm(key.to_s)
    val.each_pair do |x, y|
      if x == :aliases
        val[x].each do |new_alias|
          config.add_alias(key.to_s, new_alias.to_s)
        end
      elsif x == :username
        config.set(key.to_s, 'User', username)
      else
        config.set(key.to_s, x.to_s, y)
      end
    end
  end
  config
end