I want to change RSA Keys to open ssh connections without any problems. It works fine, if I use this tutorial but I want to have it done in a bash script. Unfortunately I am asked to enter a passphrase (I want to enter nothing). How can I achieve to automatically press Enter three times in a row, when the script reaches this point?
This thread did not help, because I am not allowed to install new programs on my work PC and the echo | command
trick seems only to work for one Enter. Also I need to enter "n" and Enter, if the procedure was already made, to not overwrite any files. How do i achieve that?
If you just need to press Enter a bunch of times this will do it:
yes "" | command
For anything more complicated than that you might want to use expect
as suggested in the other thread, which you can install in your homedir without root priviliges.
PS: Please avoid re-posting questions in the future. If you don't like an answer for some reason, just comment on it.
If you want to just create ssh keys in a bash script without requiring any user input, you can specify arguments to ssh-keygen
:
# rsa type (default), no passphrase, write to file id_rsa and id_rsa.pub
captain:~> ssh-keygen -t rsa -N "" -f id_rsa
Generating public/private rsa key pair.
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
fe:4a:82:08:0e:ab:b7:02:62:11:4d:3e:79:a4:d3:98 [email protected]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With