Automating “enter” keypresses for bash script generating ssh keys

后端 未结 5 708
说谎
说谎 2020-12-04 08:36

I would like to create script, which simply runs ssh-keygen -t rsa. But how to pass to it 3 times enter?

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 08:50

    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
    

提交回复
热议问题