Solved

linux shell script to automate rsa keygen

Posted on 2008-06-20
4
702 Views
Last Modified: 2013-12-16
I set up rsa key pairs on my linux for ssh connection to remote server.
After this I had to run these commands:
nohup ssh-agent -s | grep -v echo > ~/.ssh-agent  
ssh-agent
ssh-add
each time I reboot the system.

Please provide a complete script (it is only a few lines) that will execute each time the user logins to the system or the system is rebooted.
The purpose of this script is so that I dont have to enter keyphrase each time I am doing ssh operation to connect to remote server.
I am running fedora core 6.
Also please indicate in the script where do I put the keyphrase? ( asssume keyphrase is 'monkey island')
Please DO NOT answer this question if you cannot provide the script. If you just tell me put the script under certain directory, this is not an answer as I am not an expert in linux shell scripting. Please read that the question show I have indicated level of knowledge as Begiinner.
0
Comment
Question by:zenguru
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 250 total points
ID: 21834521
isn't the ssh-agent automaticly started if you login to your system, so you just can do:
ssh-add

For security reasons there is no option to pass the passphrase to the command. You will need to enter the password once after you logged in into your system.

To check fo a running agent type directly after reboot and login in a shell

ps axfu | grep ssh-agent

If you see one running you just type ssh-add
0
 
LVL 48

Expert Comment

by:Tintin
ID: 21834858
ssh-agent is intended for interactive use.  You could automate it with expect, but that would defeat the purpose of having it in the first place.

0
 
LVL 28

Assisted Solution

by:Jan Springer
Jan Springer earned 250 total points
ID: 21841359
Origination server:

$ ssh-keygen -t rsa
   -> hit enter twice through the passwords

Destination server:

# mkdir /<home>/<username>/.ssh
# chmod 0700 /<home>/<username>/.ssh"

Origination server:

$ scp .ssh/id_rsa.pub <server>:.ssh/authorized_keys
   -> you will be prompted for the password

Successive sftps, scps and ssh will not ask for a password.

Substitute "<home>", "<username>" and "<server>" for the applicable information
0
 
LVL 28

Expert Comment

by:Jan Springer
ID: 21841372
also, I should add that this is a one-time configuration.  it will remain across reboots.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Utilizing an array to gracefully append to a list of EmailAddresses
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now