LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SSH RSA passphrase in script ? (https://www.linuxquestions.org/questions/linux-newbie-8/ssh-rsa-passphrase-in-script-843025/)

jonaskellens 11-08-2010 09:15 AM

SSH RSA passphrase in script ?
 
Hello,

when generating RSA public/private key pair, I gave a passphrase to protect the key.

When I now want to use this private key in a script to log on to the remote server via ssh and do something, how can I give the passphrase ??

Alternatively, is it possible to use a different private key without passphrase ? I doubt it, but it doesn't harm to ask.

Tinkster 11-08-2010 10:28 AM

What's the task at hand, is it going to be running as cron-job
for a system user?

You could use "expect" to script the pass-phrase, but that's
always a bad idea.

You could generate a new account and have it use a passwordless
key to connect to the same user (you can't -trivially- have
two key-pairs for one user).

You could use ssh-agent & ssh-add for the account in question,
which means you'd have to manually enter the passphrase when the
machine gets rebooted.


Cheers,
Tink

rn_ 11-08-2010 10:34 AM

Quote:

Originally Posted by jonaskellens (Post 4152710)
Hello,

Alternatively, is it possible to use a different private key without passphrase ? I doubt it, but it doesn't harm to ask.

yes, you can use the -i parameter to specify a different identity file


All times are GMT -5. The time now is 03:22 AM.