0

Currently in Ruby's Net::SSH and Net::SSH::Telnet library if I run

 shell = Net::SSH::Telnet.new("Dump_log" => "/dev/stdout", "Host" => "1.1.1.1")

or

 shell = Net::SSH.start("1.1.1.1")

It begins the session using my own username instead of allowing me to supply it to the session. Is there any way to make the session ask for a username, instead of me supplying the username in the constructor?

For example, when logging into a switch or router via telnet it usually asks "Username: " before it asks for "Password:", I'd like this same behaviour through SSH.

redcodefinal
  • 909
  • 3
  • 11
  • 24

1 Answers1

0

You can use something like this

require 'net/ssh'
puts "Enter user name"
user_name = gets.chomp
Net::SSH.start('10.1.2.248', user_name) do |session|
  puts "yeo!! connected !!"
end
Vivek
  • 86
  • 5