class Freighthop::CLI::SSH
Public Class Methods
match?(*args)
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 4 def self.match?(*args) !args.empty? # we handle guest passthrough end
new(*args)
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 8 def initialize(*args) @args = args end
Public Instance Methods
app_name()
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 65 def app_name Freighthop.app_name end
config()
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 29 def config config_path.tap do |conf| if !conf.exist? || (Time.now - conf.mtime) > 86400 File.write(conf, ssh_config) end end end
config_path()
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 57 def config_path Pathname("/tmp/freighthop.#{app_name}.ssh-config") end
guest_root()
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 69 def guest_root Freighthop.guest_root end
hostname()
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 61 def hostname Freighthop.hostname end
run()
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 12 def run Freighthop::CLI::Checks.ensure_config_exists! if shell? ssh('-i') else ssh(%Q(-c "#{Shellwords.join(@args)}")) end end
shell?()
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 21 def shell? @args.first == 'ssh' end
ssh(cmd)
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 25 def ssh(cmd) exec %Q(ssh -q -t -F #{config} #{app_name} 'cd #{guest_root}; /bin/bash -l #{cmd}') end
ssh_config()
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 37 def ssh_config <<-SSH_CONFIG.gsub(/^ /, '') Host #{app_name} HostName #{hostname} User vagrant Port 22 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile #{vagrant_ssh_key_path} IdentitiesOnly yes LogLevel FATAL ForwardAgent yes SSH_CONFIG end
vagrant_ssh_key_path()
click to toggle source
# File lib/freighthop/cli/ssh.rb, line 53 def vagrant_ssh_key_path Pathname('~/.vagrant.d/insecure_private_key').expand_path end