简体   繁体   English

如何记录 ssh 调试信息?

[英]How to log ssh debug info?

I need to write the output of ssh debug info into the file.我需要将 ssh 调试信息的输出写入文件。 This

ssh -v root@172.16.248.xx > result.txt
ssh -v root@172.16.248.xx 2>&1 > result.txt

doesn't work, the file result.txt is empty, but on the screen i see bunch of debug lines, like:不起作用,文件 result.txt 为空,但在屏幕上我看到一堆调试行,例如:

OpenSSH_5.3p1 Debian-3ubuntu7, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 172.16.248.xx [172.16.248.xx] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
etc

Is there a way to redirect these lines to the file?有没有办法将这些行重定向到文件?

You have to change the order of the redirections on the command line:您必须在命令行上更改重定向的顺序:

ssh -v root@172.16.248.xx >result.txt 2>&1

or just:要不就:

ssh -v root@172.16.248.xx 2>result.txt
 -E log_file
         Append debug logs to log_file instead of standard error.

显然,将此“隐藏”调试输出保存到文件的最佳方法是使用 logsave:

logsave result.txt ssh -v root@172.16.248.xx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM