How to Log Ssh Debug Info?

How to Log Ssh Debug Info?

I need to write the output of ssh debug info into the file. This

ssh -v  > result.txt
ssh -v  2>&1 > result.txt

doesn'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
etc

Is 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>&1

or 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.