?
Solved

linux shell script to automate rsa keygen

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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

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…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 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