Sha256: 6f1fb7e26ac39cc7cf18ac8c972e887f8c75955958990effd068e2b16b05d45b
Contents?: true
Size: 877 Bytes
Versions: 1
Compression:
Stored size: 877 Bytes
Contents
require 'thor' require 'sconb' require 'toml' module SshConfigToVulsConfig class CLI < Thor default_command :convert desc 'convert', 'ssh_config to vuls config.toml' def convert begin stdin = timeout(1) { $stdin.read } rescue Timeout::Error end parsed = Sconb::SSHConfig.parse(stdin) config = { servers: {} } parsed.each do |host, detail| next if host =~ /\*/ next if detail.key?('Match') next unless detail.key?('Host') next unless detail.key?('IdentityFile') key_path = File.expand_path(detail['IdentityFile'].first) config[:servers][detail['Host']] = { host: detail['Hostname'], user: detail['User'] || 'root', port: detail['Port'] || '22', keyPath: key_path } end puts TOML.dump(config) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ssh_config_to_vuls_config-0.1.0 | lib/ssh_config_to_vuls_config/cli.rb |