Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
288 views
in Technique[技术] by (71.8m points)

debugging - 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?

question from:https://stackoverflow.com/questions/7533661/how-to-log-ssh-debug-info

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...