Hi,
I would like to create script, which simply runs ssh-keygen -t rsa
. But how to pass to it 3 times enter?
views:
41answers:
2
+5
A:
Try:
ssh-keygen -t rsa -N "" -f my.key
-N ""
tells it to use an empty passphrase (the same as two of the enters in an interactive script)
-f my.key
tells it to store the key into my.key
(change as you see fit).
The whole thing runs without you needing to supply any enter keys :)
To send enters to an interactive script:
echo -e "\n\n\n" | ssh-keygen -t rsa
Rudu
2010-09-07 14:42:06
It is correct anwser, but i still would like to know how to press enter more then one time - in another script.
Sławosz
2010-09-07 14:45:10
Sure thing - updated the answer to include how to send newlines to a script.
Rudu
2010-09-07 14:47:31
echo -e "\n\n\n" | sshkeygen -t rsa is not working for me, can you try it yourself? It pass only first enter. But on other, simple script it works.
Sławosz
2010-09-08 10:00:14
I tested it before I posted it - it works fine, although it looks like the dash from `ssh-keygen` got dropped - did you add that back in? {edited} Also - you can't run the script more than once - it changes the questions to confirm you want to overwrite the existing `_rsa` keyfile (so a y or n needs to be supplied)
Rudu
2010-09-08 13:23:11