Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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