LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-18-2011, 05:50 AM   #1
say_hi_ravi
Member
 
Registered: Jan 2008
Posts: 68

Rep: Reputation: 15
Pass carriage return to a command


Guys,

How can I pass carriage return to a command. I am writing a shell script whcih generates ssh key pair. It ask for input from user three times. I want to pass carriage return (ie. press Enter button) to this command. Is tehre any way?

Thanks,
Ravi
 
Old 02-18-2011, 05:58 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Are you using the ssh-keygen command? Basically you will be prompted for key name and twice for the passphrase, unless you provide them with options. For example:
Code:
ssh-keygen -N "" -f goofy
will create the goofy/goofy.pub pair with an empty passphrase, without prompting the user. Is this what you're looking for?
 
Old 02-18-2011, 06:06 AM   #3
say_hi_ravi
Member
 
Registered: Jan 2008
Posts: 68

Original Poster
Rep: Reputation: 15
Colucix,

Thanks for the reply. And yes I am using ssh-keygen command to generate ssh key pair. But I am not after creating empty passphrase. I basically want to pass NOTHING when it prompts for key name or passphrases and need to do it through a script in order to avoid manual intervention.

-Ravi
 
Old 02-18-2011, 06:25 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Hmm... maybe I'm missing something. The -N option with an empty string as argument equals to pass NOTHING when prompted for passphrase. Also when you hit return without entering a string when prompted for key name, it will create a default key, being either $HOME/.ssh/id_rsa or $HOME/.ssh/id_dsa depending on the key type, so that you can give the default name along with the -f option. If I've not understood the problem, please tell me and elaborate further.
 
Old 02-18-2011, 08:04 AM   #5
say_hi_ravi
Member
 
Registered: Jan 2008
Posts: 68

Original Poster
Rep: Reputation: 15
I am using below:

ssh-keygen -N "" -t dsa

and it asked me for passphrase!

$ ssh-keygen -N "" -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/testid/.ssh/id_dsa):

Quote:
Also when you hit return without entering a string when prompted for key name, it will create a default key, being either $HOME/.ssh/id_rsa or $HOME/.ssh/id_dsa depending on the key type, so that you can give the default name along with the -f option.
I do not want to press enter button at all! :-)
 
Old 02-18-2011, 08:08 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
From your last post it looks like it asks the key name, not the passphrase. Please try:
Code:
ssh-keygen -N "" -t dsa -f $HOME/.ssh/id_dsa
 
Old 02-18-2011, 08:11 AM   #7
say_hi_ravi
Member
 
Registered: Jan 2008
Posts: 68

Original Poster
Rep: Reputation: 15
Bingo!

It worked. Thanks a ton colucix! :-)
 
Old 02-18-2011, 08:14 AM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
You're welcome!
 
Old 02-19-2011, 04:17 AM   #9
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
say_hi_ravi,

If you'd like this moved to Programming, ask by using the "Report" button.
 
  


Reply

Tags
ssh-keygen


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Minicom carriage return + hyperterminal kewl Linux - Software 2 03-22-2010 12:27 PM
carriage return mike2008 Linux - Newbie 3 10-15-2009 01:03 AM
vsftpd carriage return issue taylorjp75 Linux - Software 1 07-14-2009 07:55 AM
carriage return in emac lisp balloon Programming 1 11-23-2004 09:29 AM
pppd...carriage return?!? icyfire Linux - Software 1 02-14-2002 08:07 AM


All times are GMT -5. The time now is 02:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration