基于问题Key based authenication with net-sftp in Ruby ,我可以使用以下命令通过基于 key 的身份验证进行 SFTP:
Net::SFTP.start(host, "user", keys:['~/.ssh/my_key']) do |sftp|
sftp.upload! "/local/file.tgz", "/remote/file.tgz"
end
但是我无法让它适用于需要密码的 key - 我只是收到提示用户在该主机上登录。我是否遗漏了一些可以让我输入 key 密码的内容?或者我是否需要坚持使用 ssh-agent
来实现此目的?
最佳答案
有密码
选项:
the passphrase to use when loading a private key (default is
nil
, for no passphrase)
如果您没有指定密码
,系统会要求您输入密码,除非您使用non_interactive
选项:
set to true if your app is non interactive and prefers authentication failure vs password prompt
non interactive applications should set it to true to prefer failing a password/etc auth methods vs asking for password
关于ruby - Ruby 中使用 net-sftp 进行基于密码 key 的身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37667617/