Solved

linux shell script to automate rsa keygen

Posted on 2008-06-20
4
711 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Utilizing an array to gracefully append to a list of EmailAddresses
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 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…

832 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