简体   繁体   English

SSH隧道无法重新打开。 没有权限

[英]SSH tunnel can't reopen. Permission Denied

I have an IoT device I'm working on. 我有正在使用的IoT设备。 I need to be able to reliably SSH into it once it's out in the field since I won't have physical access if I need to modify any files. 一旦它进入现场,我需要能够可靠地SSH进入它,因为如果需要修改任何文件,我将没有物理访问权限。 I have a startup script that uses the following line to open an SSH tunnel: 我有一个启动脚本,该脚本使用以下行打开SSH隧道:

sshpass -p 'XXXXXX' ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -fN -R 7000:localhost:22 user@server-address.com

This is successful at opening a tunnel, but if power is interrupted I can no longer open a tunnel without changing port number. 这样可以成功打开隧道,但是如果电源中断,我将无法在不更改端口号的情况下打开隧道。

Here is the output with -vvv: 这是-vvv的输出:

debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug3: no such identity: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug3: no such identity: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug3: no such identity: /root/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
debug3: packet_send2: adding 48 (len 61 padlen 19 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.

I'm running Debian on an Intel Edison. 我在Intel Edison上运行Debian。

I eventually duct-tape-coded this into submission with an endless loop that just tries over and over. 我最终用无休止的循环反复尝试,用胶带将其编码成提交。 Not sure why this works, but I sure as hell won't find out from this website. 不知道为什么这行得通,但是我敢肯定不会从这个网站上找到。

And since my reputation isn't high enough to post on meta... 而且由于我的声誉不够高,无法发布在元数据上...

To future people with this question: Every time I come here and find questions on my issue, the question is either downvoted to hell with no answers or all the comments are just mean in general. 对于将来遇到此问题的人:每当我来这里查找有关我的问题的问题时,该问题要么被打成地狱,没有任何答案,要么所有评论都只是一般性的意思。 Stuff like "why bother doing that" or "duplicate" (when its clearly not) aren't helpful. 诸如“为什么要这样做”或“重复”(显然没有这样做)之类的东西没有帮助。 I tried asking questions myself hoping for better responses, but got none. 我本人试图问一些问题,希望能得到更好的答复,但没有得到。 Screw this site, Reddit is more helpful. 拧这个站点,Reddit会更有帮助。

Looks like your older tunnel are still utilizing connection on port 22 and that's why you can't establish connection again. 看起来您的旧隧道仍在使用端口22上的连接,这就是为什么您无法再次建立连接的原因。

You can fix that by provide SSH session timeout on the server side in the sshd.conf file: 您可以通过在sshd.conf文件的服务器端提供SSH会话超时来解决此问题:

ServerAliveInterval 30

You need to be sure that your device boot time is more that this number! 您需要确保您的设备启动时间超过该数字!

Take a look here for more details. 在这里查看更多详细信息。

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

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