Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于回答SSH密钥生成问题的bashshell脚本_Shell_Scripting_Public Key Encryption_Ssh Keys_Openssh - Fatal编程技术网

用于回答SSH密钥生成问题的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

我想回答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 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