Scenario
We have an RSA Key with a password
that we are attempting to use
to run SSH
commands on a remote server via a BASH
script.
We have attempted to pipe the RSA Key's password
into the SSH command
using the sshpas
program. e.g:ssh-test.sh
:
#!/bin/bash
# sshpass -e uses the SSHPASS Environment Variable:
sshpass -e ssh -i ./deploy_key root@$132.62.16.142 pwd
Note: at present this "sample command" is just attempting to print the working directory on the server for "testing", but the idea is that it will run other more useful commands via SSH.
When we execute the (above) BASH script it does not throw any errors,
it just "hangs" with no output.
e.g:
https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384010921#L521
Question
What is the "secret" to using an RSA Key with a password
for SSH requests
in a BASH
script? (what am I doing wrong...?)
Additional Context
Our Quest is to use the Travis-CI (Online Continuous Integration Service) to deploy our App to a Centos (or FreeBSD) server. The SSH key is generated by a script that assigns a random "strong" password. We are aware that it is possible to "strip" the RSA Key password however this is not an option for us.
The RSA Key password
is encrypted (using the travis
CLI) and stored in the .travis.yml
file which only Travis can decrypt and make available as a secure environment variable $SSHPASS
(used above in the script).
This question is a distinct from other SO questions in that we are using an SSH (RSA) Key with a
password
whereas others are using Key without a password. We want to use SSH (RSA) Key with the password (which is stored as an encrypted environment variableSSHPASS
) for security/compliance reasons.
We looked at: