2

Can someone please shed some light on this issue I have with net-ssh. I am new to ruby and am working on this project.

How do I tell net ssh to use the username and password provided to connect to the servers without needing to have a shared key between my machine and those servers?

def connect
  Net::SSH.start("#{@servername}", "#{username}", :password => "#{password}") do |ssh|
    result = ssh.exec!("ls #{@dirname}").chomp
    puts result
  end #ssh
end
dcharles
  • 4,822
  • 2
  • 32
  • 29

1 Answers1

0

It's not clear really what you're asking here. You appear to be using the Net::SSH api correctly, at least according to its docs.

One concern is your use of "#{@servername}" which is a redundant use of variable interpolation. There's no need for any of the quotes around servername, username or password.

However, please be clearer about your problem. Are you asking how you can pass these values in to your script, or is there a problem with Net::SSH accepting them?

noodl
  • 17,143
  • 3
  • 57
  • 55