LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Pass carriage return to a command (https://www.linuxquestions.org/questions/linux-newbie-8/pass-carriage-return-to-a-command-863502/)

say_hi_ravi 02-18-2011 04:50 AM

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

colucix 02-18-2011 04:58 AM

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?

say_hi_ravi 02-18-2011 05:06 AM

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

colucix 02-18-2011 05:25 AM

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.

say_hi_ravi 02-18-2011 07:04 AM

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! :-)

colucix 02-18-2011 07:08 AM

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

say_hi_ravi 02-18-2011 07:11 AM

Bingo!

It worked. Thanks a ton colucix! :-)

colucix 02-18-2011 07:14 AM

You're welcome! :)

archtoad6 02-19-2011 03:17 AM

say_hi_ravi,

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


All times are GMT -5. The time now is 09:51 AM.