开发者

Net-SSH Ruby Authentication

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


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜