ssh
为了autossh -M0
方便起见,我使用了别名,它运行良好。
但是它总是错误地退出,这会导致我的脚本出现问题。
例如
ssh me@myserver 'true' # equivalent to: autossh -M0 me@myserver 'true'
echo $? # 1
我该如何解决?
(脚本中的一种解决方法,它可以/usr/bin/ssh
代替ssh
. 但如果可能的话,我想解决这个问题。)
我有一个幼稚的问题,但是通过阅读这个线程,例如:https ://superuser.com/questions/37738/how-to-reliably-keep-an-ssh-tunnel-open
可以在接受的答案中看到如何使用autossh
,例如:
autossh -M 20000 -f -N your_public_server -R 1234:localhost:22 -C
但是从autossh
https://manpages.ubuntu.com/manpages/focal/man1/autossh.1.html的手册页我只能看到 3 个可用选项-M
:-f
和-V
.
在我的系统上同样的事情:
$ autossh --help
/usr/lib/autossh/autossh: invalid option -- '-'
usage: autossh [-V] [-M monitor_port[:echo_port]] [-f] [SSH_OPTIONS]
-M specifies monitor port. Overrides the environment
variable AUTOSSH_PORT. 0 turns monitoring loop off.
Alternatively, a port for an echo service on the remote
machine may be specified. (Normally port 7.)
-f run in background (autossh handles this, and does not
pass it to ssh.)
-V print autossh version and exit.
Environment variables are:
AUTOSSH_GATETIME - how long must an ssh session be established
before we decide it really was established
(in seconds). Default is 30 seconds; use of -f
flag sets this to 0.
AUTOSSH_LOGFILE - file to log to (default is to use the syslog
facility)
AUTOSSH_LOGLEVEL - level of log verbosity
AUTOSSH_MAXLIFETIME - set the maximum time to live (seconds)
AUTOSSH_MAXSTART - max times to restart (default is no limit)
AUTOSSH_MESSAGE - message to append to echo string (max 64 bytes)
AUTOSSH_PATH - path to ssh if not default
AUTOSSH_PIDFILE - write pid to this file
AUTOSSH_POLL - how often to check the connection (seconds)
AUTOSSH_FIRST_POLL - time before first connection check (seconds)
AUTOSSH_PORT - port to use for monitor connection
AUTOSSH_DEBUG - turn logging to maximum verbosity and log to
stderr
和选项从何而来-N
?我没有找对地方吗?-R
-C