Stop SSH password prompts in serverspec

1.4k views Asked by At

I'm in an environment with authentication tokens, so typically a SSH password is not required. My serverspec tests are always asking me for a password. Is there a way to prevent this?

No password required:

$ ssh atlspf01
newatson@atlspf01:~$

Yet, in serverspec

$ rake spec
Password:

Relevant code in spec_helper.rb

require 'serverspec'
require 'net/ssh'

set :backend, :ssh
...
set :host, ENV['TARGET_HOST']
set :ssh_options, :user => ENV['USERNAME']

UPDATE: Problem is that net::ssh does not support Kerberos authentication (gssapi-with-mic). Use ssh::ssh::kerberos or use ssh keys.

1

There are 1 answers

7
egwspiti On BEST ANSWER

On your configuration, you only pass info about user to ssh_options

Assuming that your target host is stored into environmental variable TARGET_HOST and username is stored into USERNAME, you should do something like this:

set :ssh_options, Net::SSH::Config.for(ENV['TARGET_HOST']).merge(user: ENV['USERNAME'])