How to log ssh debug info?
Andrew Henderson
I need to write the output of ssh debug info into the file. This
ssh -v > result.txt
ssh -v 2>&1 > result.txtdoesn't work, the file result.txt is empty, but on the screen i see bunch of debug lines, like:
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
etcIs there a way to redirect these lines to the file?
3 Answers
You have to change the order of the redirections on the command line:
ssh -v >result.txt 2>&1or just:
ssh -v 2>result.txt -E log_file Append debug logs to log_file instead of standard error. 1 Apparently the best way to save this "hidden" debug output to the file is by using logsave:
logsave result.txt ssh -v 1