2

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?

Community
  • 1
  • 1
MrDuk
  • 16,578
  • 18
  • 74
  • 133

1 Answers1

2

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

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 1
    can you point to docs for that? i see nothing in the rdoc regarding a 'passphrase` option – ptierno Jun 07 '16 at 06:30
  • 3
    A code is the best documentation: https://github.com/net-ssh/net-ssh/blob/bfcc0fdbacd2f049b718bb8f204d07fb85520c43/lib/net/ssh.rb#L162 – Martin Prikryl Jun 07 '16 at 06:37
  • 1
    thx, and i would recommend to the `net-sftp` authors to mention referencing the net-ssh docs. http://www.rubydoc.info/gems/net-sftp/2.0.5/Net/SFTP this doc does not make that obvious. – ptierno Jun 07 '16 at 06:41
  • So, I don't get prompted for a passphrase. I just get `Authentication failed for user sftpuser@host.abc.com (Net::SSH::AuthenticationFailed)`, even when setting `:non_interactive => false` – MrDuk Jun 14 '16 at 20:43
  • That's a different problem. Ask a new question. – Martin Prikryl Jun 15 '16 at 05:38