我可以将我的密码回显给两个命令吗?
我想登录到远程计算机,并使用单个命令将我的主目录安装到那里。我尝试这样做:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为对于这项任务,使用公钥应该更舒适、更安全。这真的很简单,并且有很多教程。
请记住不要在密码中输入任何内容,否则就像必须输入密码一样。
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.
我同意弗朗西斯科·普加的观点。但有时你确实必须做这样的事情(脏),解决方案是 expect
I agree with Francisco Puga. But sometimes you really have to do things like this (dirty) and the solution is expect