用于回答SSH密钥生成问题的bashshell脚本
我想回答bashshell中出现的问题 例: 看剧本用于回答SSH密钥生成问题的bashshell脚本,shell,scripting,public-key-encryption,ssh-keys,openssh,Shell,Scripting,Public Key Encryption,Ssh Keys,Openssh,我想回答bashshell中出现的问题 例: 看剧本 #!/bin/bash ssh-keygen -t rsa #it will appear a question >> Enter file in which to save the key # (/root/.shh/id_rsa) so how can i read answer from the user(which is the path) # and **enter it to be the answer of t
#!/bin/bash
ssh-keygen -t rsa
#it will appear a question >> Enter file in which to save the key
# (/root/.shh/id_rsa) so how can i read answer from the user(which is the path)
# and **enter it to be the answer of the question.
尝试执行此操作(无需使用STDIN
):
你读过书吗
man ssh-keygen
?=) 如果您已经知道要存储输出的文件名,可以在脚本的命令行中指定,如下所示:
ssh-keygen -t rsa -f keyfile
否则,您可以要求用户指定名称,否则使用提供的参数。如果没有在命令行上传递名称,此方法将允许用户指定名称。(用法是:您的scriptname键文件名)
ssh-keygen -t rsa -f keyfile
if [ $# -eq 0 ]; then
read -p "Enter filename for key: " keyfile
ssh-keygen -t rsa -f $keyfile
else
ssh-keygen -t rsa -f $1
fi