Skip to content

Instantly share code, notes, and snippets.

@mjc
Created March 31, 2015 23:14
Show Gist options
  • Save mjc/1aac06cfae1ad9ac9e98 to your computer and use it in GitHub Desktop.
Save mjc/1aac06cfae1ad9ac9e98 to your computer and use it in GitHub Desktop.
export users and hostnames to ssh_config format
#!/usr/bin/env ruby
require 'pathname'
path = Pathname.new(ENV['HOME']).join("Library","Application Support","VanDyke","SecureCRT","Config”,”Sessions”,”**.ini")
paths = Dir.glob(path)
paths.each do |path|
lines = File.readlines(path)
hostname = nil
username = nil
lines.each do |line|
result = line.match(/S:"(.+)"=(.+)/)
next unless result
case result[1]
when "Username"
username = result[2]
when "Hostname"
hostname = result[2]
end
end
next unless hostname && username
puts "Host %s" % hostname
puts "HostName %s" % hostname
puts "User %s" % username
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment