I read man ssh-add
and I don't see a flag for passing a passphrase like we have in .ssh
which is -p
I tried
# the -K is for macOS's ssh-add but it's not relevant
ssh-add -q -K ~/.ssh/id_rsa <<< $passphrase
But I get the following output:
ssh_askpass: exec(/usr/X11R6/bin/ssh-askpass): No such file or directory
How can I pass a password w/o triggering a prompt
Update
Adding more context to what I'm doing, I'm creating a script to create SSH keys for me. It will generate the passphrase, the SSH key using that passphrase, and add it to the agent.
# ...
passphrase=$(generate_password)
ssh-keygen -t rsa -b 4096 -C $email -f $filename -N $passphrase -q
ssh-add -q -K $filename
Following Stephen's answer, I'm not sure how would that work. Seems like I'd had to create a temporal script and save it to disk, in order for SSH_ASKPASS to work. Any ideas?
<<< $passphrase
) will use a temporary file and store the passphrase into it (at least in bash, ksh and zsh)