5

I have a text of a private key file. I want to connect via ssh to other node, yet the gateway I am in does not provide me with file system access. How to pass a text representation of key and not a file with it to ssh client?

  • 1
    Is using ssh-agent and then ForwardAgent=yes to forward the keys contained therein possible? – thrig Jun 10 '16 at 16:09
  • 1
    Do you ssh to that gateway? And if so, does it accept forwarding of authentication agent (ssh -A gateway)? – Stéphane Chazelas Jun 10 '16 at 16:11
  • 2
    You don't even have write access to /tmp? What can you do? Can you still run arbitrary shell commands? – Stéphane Chazelas Jun 10 '16 at 16:12
  • @ Stéphane Chazelas: I was able to run arbitrary shell commands and had write access to /tmp and I was allowed to set chmod on created in /temp file. This solved my problem, thank you! – DuckQueen Jun 10 '16 at 19:24
  • 1
    Bad idea -- anyone who can look at the process table on the gateway will be able to read the command - and thus, the key. – Shadur Jun 13 '16 at 13:19
0

It sounds like you don't really need to store your key on the bastion, but really just need to connect to something on the other side. If that's true, and provided it's not blocked by the SSH server you're connecting to, you should be able to use OpenSSH's ProxyCommand. In the following example, bastion is the external host you're using to reach into remote network.

ssh -o ProxyCommand "ssh bastion.example.com -W %h:%p" internal.example.com

Since that's not exactly easy typing, I'd recommend putting it into your ${HOME}/.ssh/config like this:

Host internal.example.com
     User username
     Hostname internal.example.com
     ProxyCommand ssh bastion.example.com -W %h:%p

Hostnames may be substituted with IP addresses if necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.