Solved

linux shell script to automate rsa keygen

Posted on 2008-06-20
4
720 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

737 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