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?
To enable SSH debug, run the SSH command with the -v, -vv, or -vvv option: In this example, you can see what a successful SSH connection would look like with the complete back and forth communication between the hosts.
On most modern systems, journalctl provides a convenient, standardized way to view ssh logs. On other systems, you can find the sshd log at /var/log/auth. log. For quick inspections, you can also use the lastlog command.
The ssh client's -v switch allows you to run ssh in verbose mode, that prints debugging information about SSH connection progress, which is really useful for debugging connections, authentication, and any configuration problems.
Troubleshooting steps:Verify that the host IP address is correct. Verify the firewall rules, check the inbound rules allowed by the security group. Verify the port number allowed for ssh. Verify that the service is running properly.
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
-E log_file Append debug logs to log_file instead of standard error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With