I have a simple functional for run some command via ssh, here is an example:
Net::SSH.start( self.host, self.user, config: true, keys: [self.pem_key] ) do| ssh |
result = ssh.exec! self.command
Completed 200 OK in 246ms (Views: 238.1ms | ActiveRecord: 4.3ms)
Started POST "/xxx" for ::1 at 2016-05-24 13:43:11 +0300
Processing by XXX::XXXController#run_now as JS
XXX::Check Load (0.3ms) SELECT ...
SQL (0.3ms) UPDATE ...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
According to the documentation, the
Net::SSH.start method accepts a
:non_interactive => true option which should make your test (code) fail instead of asking for a password interactively. Other, non-interactive authentication options, such as the private key, will of course still work.
So, try this:
Net::SSH.start(self.host, self.user, config: true, non_interactive: true, keys: [self.pem_key]) do| ssh | ... end