tee 无法使用运行外部脚本的 ssh

问题描述 投票:0回答:2

我正在尝试记录 ssh 会话期间发生的所有事情,同时在 shell 上显示输出。

sshpass -p "password" ssh -tt -o ConnectTimeout=10 -oStrictHostKeyChecking=no username@"$terminal" 'bash -s' < libs/debug-mon.lib "$function" | grep -E '^INFO:|^WARNING:' || echo "WARNING: Terminal not reacheable or wrong IP" | tee -a libs/debug-monitor-logs

我在日志 libs/debug-monitor-logs 文件中没有得到任何信息 你能帮我看看问题出在哪里吗?

谢谢

bash shell tee
2个回答
0
投票

看起来你唯一会写入日志文件的是“警告:终端无法访问或 IP 错误”

尝试这样的事情

(command-that-might-fail || echo error message) | tee -a log-file

代替

commant-that-might-fail || echo error message | tee -a log-file

(将整个表达式放在括号中,表示要通过管道传输到 tee 中)


0
投票

查看SSHLog:https://github.com/sshlog/agent/

它是一个监控 SSH 登录和用户活动的守护进程。所有用户活动(在 shell 上发生的一切)都被被动记录并可用于传输到日志文件、远程系统日志服务器等。

© www.soinside.com 2019 - 2024. All rights reserved.