Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-08-2010, 09:15 AM   #1
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 643

Rep: Reputation: 33
SSH RSA passphrase in script ?


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.
Old 11-08-2010, 10:28 AM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
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.


Last edited by Tinkster; 11-08-2010 at 10:30 AM.
Old 11-08-2010, 10:34 AM   #3
Registered: Jun 2009
Location: Orlando, FL, USA
Distribution: Suse, Redhat
Posts: 127
Blog Entries: 1

Rep: Reputation: 25
Originally Posted by jonaskellens View Post

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh-keygen -t rsa -b 2048 without a passphrase sycamorex Linux - Security 7 06-10-2010 04:42 PM
SSH no-password authentication: RSA Passphrase Nokao Linux - Server 8 12-28-2009 10:17 AM
passphrase authentication fails using rsa with OpenSSH 5.1p1 (Slackware 12.2) sysfce2 Linux - Newbie 16 11-01-2009 08:21 PM
SSH without a password or passphrase Chocolate Linux - Networking 4 03-04-2007 02:59 AM
ssh / ssh-key -- its always asking for passphrase BaerRS Linux - General 1 01-07-2003 06:21 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:01 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration