0
autossh -M 10984 -v -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -R 6889:localhost:22 user@rpi.local

The above command works. The one below doesn't.

autossh -M 10984 -E /home/pi/ssh.log -v -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -R 6889:localhost:22 user@rpi.local

It says,

/usr/lib/autossh/autossh: invalid option -- 'E'`

How can I specify a log file as the SSH option when passing it to autossh?

4

1 回答 1

1

这是一个限制autossh。autossh 源代码包含程序接受的命令行开关列表。该列表显然应该包括所有 ssh 选项,但不包括“E”:

#define OPTION_STRING "M:V1246ab:c:e:fgi:kl:m:no:p:qstvw:xyACD:F:I:MKL:NO:PR:S:TVXY"
...
/*
 * We accept all ssh args, and quietly pass them on
 * to ssh when we call it.
 */
while ((ch = getopt(argc, argv, OPTION_STRING)) != -1) {
    switch(ch) {
    case 'M':
...

目前似乎有一些解决方法:

  1. 使用指向所需文件的标准错误运行 autossh:

    autossh -M 10984 -v -o ... user@rpi.local 2>>/some/log/file
    

    从 autossh 启动的 SSH 实例应该继承重定向。

  2. 使用 ssh “-y” 选项通过 syslog 记录,并让 syslog 将消息写入您希望写入的位置。
  3. 修改autossh 源代码以添加对“-E”选项的支持。
  4. 将问题报告给autossh 维护者,并希望他在以后的版本中修复它。
于 2016-11-14T14:54:31.710 回答