【问题标题】:Autossh not accepting logfile option for sshAutossh 不接受 ssh 的日志文件选项
【发布时间】:2016-11-14 23:29:15
【问题描述】:
autossh -M 10984 -v -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -R 6889:localhost:22 user@rpi.local

上述命令有效。下面的没有。

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

它说,

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

在将日志文件传递给 autossh 时如何将其指定为 SSH 选项?

【问题讨论】:

  • 选项应该被传递给ssh。你用的是什么版本?
  • 我正在使用 autossh 版本 1.4d。我也对 1.4e 版本进行了同样的尝试。结果相同。
  • 我刚刚使用了包管理器。我在 Raspberry Pi 2 上运行 Raspbian。我在笔记本电脑上运行 Arch Linux。

标签: ssh autossh


【解决方案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 source code 以添加对“-E”选项的支持。
  4. 将问题报告给autossh maintainer,希望他在以后的版本中修复它。

【讨论】:

  • 第一个解决方法将只重定向来自 autossh 的错误,而不是它启动的 ssh 进程。对吗?
  • 当一个进程启动另一个进程时,正常行为是新进程继承旧进程的标准文件句柄。我自己不使用 autossh,但它的文档没有描述对 ssh 子进程的标准错误做任何特殊的事情,所以我希望 ssh 继承 autossh 的标准错误。你可以试试看会发生什么。
猜你喜欢
  • 2019-01-23
  • 2022-11-03
  • 2018-06-10
  • 1970-01-01
  • 2018-05-02
  • 1970-01-01
  • 2016-05-13
  • 2015-09-08
  • 2013-08-22
相关资源
最近更新 更多