lugger1
lugger1

Reputation: 1917

How to log ssh debug info?

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

ssh -v [email protected] > result.txt
ssh -v [email protected] 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?

Upvotes: 51

Views: 145594

Answers (3)

Bhoodha
Bhoodha

Reputation: 51

As per the docs you can use the -E option to store debug logs in file:

 -E log_file
         Append debug logs to log_file instead of standard error.

Upvotes: 5

salva
salva

Reputation: 10244

You have to change the order of the redirections on the command line:

ssh -v [email protected] >result.txt 2>&1

or just:

ssh -v [email protected] 2>result.txt

Upvotes: 66

lugger1
lugger1

Reputation: 1917

Apparently the best way to save this "hidden" debug output to the file is by using logsave:

logsave result.txt ssh -v [email protected]

Upvotes: -7

Related Questions