Skip to content

Instantly share code, notes, and snippets.

@nanotechz9l
Last active August 29, 2015 13:56
Show Gist options
  • Save nanotechz9l/9337562 to your computer and use it in GitHub Desktop.
Save nanotechz9l/9337562 to your computer and use it in GitHub Desktop.
ssh.rb
#!/usr/bin/env ruby
require 'net/ssh' # more details: https://github.com/net-ssh/net-ssh
require 'logger'
if not ARGV[2]
puts "\n[Auto SSH login by Rick Flores (@nanotechz9l)]"
puts "Missing arguments. Correct useage below:\n"
puts "#{$0} ip user pass"
exit(0)
end
ip, user, pass = ARGV[0..2]
Net::SSH.start("#{ip}", "#{user}", :password => "#{pass}") do |ssh|
puts "SSH Login successful..."
puts "Logging out..."
#ssh.exec "hostname;w;ifconfig" # command chains
#print "Hostname ="
#ssh.exec "hostname\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment