0

Presumably ssh tries to access the fd several times, but the fd is destroyed after it has been read the very first time:

# ssh -i <(echo $KEY) user@example.com
Warning: Identity file /dev/fd/11 not accessible: Bad file descriptor.
user@example.com: Permission denied (publickey).

Is there any other way without writing/removing temporary file?

  • The tool for handling keys is called an agent. You would add the contents of your variable to the agent and ssh would get it from the agent. Therefore this answer on Stack Overflow is your solution – Bananguin Apr 23 at 12:14
  • Agent is not always available, also I want a solution which would work well in scripts. – NarūnasK Apr 23 at 12:22
  • 3
    The agent approach does work well in scripts and ssh-agent is usually part of ssh installations. If you have special constraints you should put them in your question, because we cannot guess those. – Bananguin Apr 23 at 12:27
  • This feels like a really bad idea. Can you explain the context here. What are you trying to achieve? Why have you rejected the idea of storing keys in files? – Philip Couling Apr 23 at 12:50
  • Where does the contents of $KEY come from? – Kusalananda Apr 23 at 13:55

Your Answer

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

Browse other questions tagged or ask your own question.