Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

linux shell script to automate rsa keygen

Posted on 2008-06-20
4
Medium Priority
?
735 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 1000 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 29

Assisted Solution

by:Jan Springer
Jan Springer earned 1000 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 29

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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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 …
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.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

604 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