【问题标题】:autossh quits because ssh (dropbear) can't resolve hostautossh 退出,因为 ssh (dropbear) 无法解析主机
【发布时间】:2015-12-18 13:01:35
【问题描述】:

我在可能有或没有互联网连接的系统上运行 autossh。我真的不知道它何时有连接,但如果有,我希望 autossh 通过以下方式建立 ssh 隧道:

autossh -M 2000 -i /etc/dropbear/id_rsa -R 5022:localhost:22 -R user@host.name -p 6022 -N

几秒钟后它抛出:

/usr/bin/ssh: Exited: Error resolving 'host.name' port '6022'. Name or service not known

就是这样。 autossh 不是为了让ssh 进程无论如何都运行吗?我真的需要检查ping 左右的连接吗?

【问题讨论】:

    标签: ssh dns autossh


    【解决方案1】:

    您需要将AUTOSSH_GATETIME 环境变量设置为0。来自 autossh(1):

    Startup behaviour
     If the ssh session fails with an exit status of 1 on the very first try, autossh
    
     1.      will assume that there is some problem with syntax or the connection setup,
             and will exit rather than retrying;
    
     2.      There is a "starting gate" time. If the first ssh process fails within the
             first few seconds of being started, autossh assumes that it never made it
             "out of the starting gate", and exits. This is to handle initial failed
             authentication, connection, etc. This time is 30 seconds by default, and can
             be adjusted (see the AUTOSSH_GATETIME environment variable below). If
             AUTOSSH_GATETIME is set to 0, then both behaviours are disabled: there is no
             "starting gate", and autossh will restart even if ssh fails on the first run
             with an exit status of 1. The "starting gate" time is also set to 0 when the
             -f flag to autossh is used.
    
     AUTOSSH_GATETIME
             Specifies how long ssh must be up before we consider it a successful connec‐
             tion. The default is 30 seconds. Note that if AUTOSSH_GATETIME is set to 0,
             then not only is the gatetime behaviour turned off, but autossh also ignores
             the first run failure of ssh. This may be useful when running autossh at
             boot.
    

    用法:

    AUTOSSH_GATETIME=0 autossh -M 2000 -i /etc/dropbear/id_rsa -R 5022:localhost:22 -R user@host.name -p 6022 -N
    

    【讨论】:

    • 嗯,好的。因此,在末尾添加 -f 或在前面添加 AUTOSSH_GATETIME=0 将修复。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 2020-06-01
    • 1970-01-01
    • 2011-07-01
    • 2022-01-25
    • 1970-01-01
    相关资源
    最近更新 更多