0

I am writing an appliation that will run a shell scripts behind the scene. The command that I run in the script looks like this,

cd ~/.ssh/ && ssh-add -D && ssh-add <id_rsa_filename>

It is trying to add a private key to the ssh agent.

When this command(s) finishes running, and if the ssh private key requires a passphrase, then you get this output from the ssh agent - "Enter passphrase:"

I would like to know,

  1. If it is possible to pass a passphrase as an argument while running the ssh-add, example: ssh-add -pass <my_pass_phrase>
  2. How can I change my script to interact with the ssh-agent to pass the passphrase when prompted.

Important: I do not wish to remove the passphrase tied to the ssh-private key

  • Does this answer your question? [How to make ssh-add read passphrase from a file?](https://stackoverflow.com/questions/13033799/how-to-make-ssh-add-read-passphrase-from-a-file) – phd Feb 07 '20 at 21:55
  • https://stackoverflow.com/search?q=%5Bssh%5D+ssh-add+passphrase+stdin – phd Feb 07 '20 at 21:55
  • Unless your distro has patched them, `ssh` and `ssh-add` only read from a TTY. – bk2204 Feb 07 '20 at 23:52
  • @bk2204 Solution using `expect` is also shown in the linked answer. – phd Feb 08 '20 at 11:03

0 Answers0