简体   繁体   English

如何在bash脚本命令中提供2个输入?

[英]How to provide 2 inputs in a bash script command?

I am trying to mount a remote folder on to my computer using sshfs. 我正在尝试使用sshfs将远程文件夹安装到我的计算机上。 my bash script is as follows: 我的bash脚本如下:

sudo sshfs -o allow_other id@afs1.domain.com:/ /home/kr1shna/remote -o password_stdin <<<"xxxxxx"

and everytime i execute this, it prompts me for the root password. 每次执行此操作时,都会提示我输入root密码。

so i tried: 所以我尝试了:

echo "rootpassword" | sudo -S sshfs -o allow_other id@afs1.domain.com:/ /home/kr1shna/remote -o password_stdin <<<"xxxxxx"

I know its not a good habit to echo my root password, but I'm the only one who uses this computer. 我知道回显我的root密码不是一个好习惯,但是我是唯一使用此计算机的人。

In what way can I provide the root password and the other password parameter in the bash script? 我可以通过什么方式在bash脚本中提供root密码和其他password参数?

Thank you. 谢谢。

Try defining the values you want to pass to a command. 尝试定义要传递给命令的值。

For example 例如

password="$(echo 'HelloWorld!')";
echo "Your password is $password";

In your case, it would be: 在您的情况下,它将是:

password="$(echo 'xxxxx')"
sudo sshfs -o allow_other id@afs1.domain.com:/ /home/kr1shna/remote -p $password

And I know you're probably getting annoyed with us all telling you to not do this, but this really does pose a potential security flaw to your server. 而且我知道您可能对我们所有人都感到恼火,告诉他们不要这样做,但这确实确实对您的服务器构成了潜在的安全漏洞。 I would highly recommend against doing this. 强烈建议您不要这样做。

Why not generate the ssh pub keys and login ssh without inputting password. 为什么不输入密码就不生成ssh pub密钥和登录ssh。 Lots of distributed clusters do it this way. 许多分布式集群都是通过这种方式实现的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM