I need to write the output of ssh debug info into the file. 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:

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?

share|improve this question

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
share|improve this answer

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

logsave result.txt ssh -v root@172.16.248.xx
share|improve this answer
2  
Not at all necessary. It's not "hidden" debug info. It's STDERR, which you're redirecting to STDOUT. STDOUT is what you're redirecting, but you're doing this after you set STDERR to write to the same file that STDOUT was writing to (the console). That is why salva's answer should work. – Kat Dec 3 '14 at 4:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.