简体   繁体   English

如何编写 bash 文件以建立 ssh 连接

[英]How to write bash file for establishing a ssh connection

I tried to write a bash file for establishing a SSH tunnel from Pi 1 to Pi2.我尝试编写一个 bash 文件来建立从 Pi 1 到 Pi2 的 SSH 隧道。 I found several guides and did it according to them - so far so good.我找到了几个指南并根据他们做了 - 到目前为止一切都很好。 Everything is working now if I type the following in the terminal:如果我在终端中键入以下内容,现在一切正常:

ssh -i .ssh/key_rsa pi@192.168.0.107

I tried the same line of code in a bash file, but there appears the following error message: „File or Dictionary not found“我在 bash 文件中尝试了相同的代码行,但出现以下错误消息:“找不到文件或字典”

My bash Code:我的 bash 代码:

#!usr/bin/bash -f

xterm -title “Terminal1“ -hold -e ssh -i “.ssh/key_rsa“ “ pi@192.168.0.107“

What's the problem here?这里有什么问题?

Are you running it from inside you $HOME where .ssh/key_rsa is located?您是从.ssh/key_rsa所在的 $HOME 内部运行它吗?
Perhaps set it to use an absolute path like $HOME/.ssh/key_rsa也许将其设置为使用绝对路径,例如$HOME/.ssh/key_rsa

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

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