Issue
I can connect to a server via SSH using the -i option to specify the private key:
ssh -i ~/.ssh/id_dsa user@hostname
I am creating a script that takes the id_dsa
text from the database but I am not sure how I can give that string to SSH. I would need something like:
ssh --option $STRING user@hostname
Where $STRING
contains the value of id_dsa
. I need to know the --option
if there is one.
Solution
There is no such switch - as it would leak sensitive information. If there were, anyone could get your private key by doing a simple ps
command.
EDIT: (because of theg added details in comment)
You really should store the key in to a temporary file. Make sure you set the permissions correctly before writing to the file, if you do not use command like mktemp
to create the temporary file.
Make sure you run the broker (or agent in case of OpenSSH) process and load the key using <whatever command you use to fetch it form the database> | ssh-add -
Answered By - Kimvais Answer Checked By - Dawn Plyler (WPSolving Volunteer)