Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passphrase Key-based authenication with net-sftp in Ruby

Based on question Key based authenication with net-sftp in Ruby, I can SFTP with key-based authentication using the following:

Net::SFTP.start(host, "user", keys:['~/.ssh/my_key']) do |sftp|
   sftp.upload! "/local/file.tgz", "/remote/file.tgz"
end

But I can't get this to work for keys that require a passphrase -- I just get prompted for the user login on that host. Am I missing something to pass in that would let me enter the passphrase for my key? Or do I need to just stick with ssh-agent for this?

like image 276
MrDuk Avatar asked Sep 18 '25 21:09

MrDuk


1 Answers

There's the passphrase option:

the passphrase to use when loading a private key (default is nil, for no passphrase)

If you do not specify the passphrase, you should get asked for one, unless you used the non_interactive option:

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

like image 72
Martin Prikryl Avatar answered Sep 20 '25 19:09

Martin Prikryl