我可以将我的密码回显给两个命令吗?

发布于 2024-12-15 19:20:13 字数 1795 浏览 0 评论 0原文

我想登录到远程计算机,并使用单个命令将我的主目录安装到那里。我尝试这样做:

echo myPassword | tee "sshfs [email protected]:/share/home/boriskh /home/boris/Work/molDyn/boriskh@hpchead" | ssh -Y [email protected] 

但它不起作用。 tee 表示它不知道 -Y 选项,如果引用这两个命令 - 它也会出错。

编辑

我发现这些东西单独放置也不起作用:

echo myPassword | ssh -Y [email protected]
echo myPassword | sshfs [email protected]:/share/home/boriskh /home/boris/Work/molDyn/boriskh@hpchead

编辑2

获得所需的功能(安装远程主页并登录那里 - 在一个命令中没有密码提示)可以通过按键轻松实现(没有密码 - 即输入 Enter 作为代码):

ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

就是这样。之后,通过以下方式实现所需的功能:

sshfs [email protected]:/share/home/boriskh /home/boris/Work/molDyn/boriskh@hpchead && ssh -Y [email protected]

I'd like to login to a remote machine, and mount my home dir there with a single command. I tried to do it with:

echo myPassword | tee "sshfs [email protected]:/share/home/boriskh /home/boris/Work/molDyn/boriskh@hpchead" | ssh -Y [email protected] 

but it doesn't work. tee says that it doesn't know the -Y option, and if quote both commands - it also works wrong.

Edit:

I found that these thiings put separately also don't work:

echo myPassword | ssh -Y [email protected]
echo myPassword | sshfs [email protected]:/share/home/boriskh /home/boris/Work/molDyn/boriskh@hpchead

Edit2:

To get the required functionality (mounting the remote home and also login there - in a single command with no password prompts) can be easily achieved with keys (with no passphrase - i.e. input Enter as a code):

ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

That's it. After that the desired functionality is achieved with:

sshfs [email protected]:/share/home/boriskh /home/boris/Work/molDyn/boriskh@hpchead && ssh -Y [email protected]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

灯角 2024-12-22 19:20:13

我认为对于这项任务,使用公钥应该更舒适、更安全。这真的很简单,并且有很多教程

请记住不要在密码中输入任何内容,否则就像必须输入密码一样。

I think that for that task it should be more comfortable and secure use public keys. It's really easy and there are lot of tutorials.

Remember not put anything in the passphrase, or it will be like have to type the password.

浮光之海 2024-12-22 19:20:13

我同意弗朗西斯科·普加的观点。但有时你确实必须做这样的事情(脏),解决方案是 expect

I agree with Francisco Puga. But sometimes you really have to do things like this (dirty) and the solution is expect

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文