Home > Networking, Windows > OpenSSH on Windows and Trouble-Shooting

OpenSSH on Windows and Trouble-Shooting

July 5th, 2017

I recently installed OpenSSH on Windows from the following site:  WinSCP.NET.  I  previously used the Cygwin version of SSH (server) but it’s not clear Cygwin maintains SSH any longer.

The instructions  at WinSCP.NET are spot on; however, I did have a problem using my public key.    In order to trouble-shoot ssh issues you have to stop the SSHD server from running and run the server in debug mode (bring up the Services dialog and stop the sshd server from running by right clicking…leave the ssh-agent service running).

Stop SSHD

Run SSHD in Debug Mode

Go to the openssh directory.  I have installed OpenSSH in “c:\program files\openssh”.  Note: the startup sshd_config file is also in this directory.   To run ssh server in debug mode, do ./sshd -ddd.  Multiple d switches increase the level of debug information (the max is 3).

 

Run SSH client in verbose mode

I can use verbose mode from the client side to see additional debug information.   You can run ssh -vvv (multiple switches increase the level of verbosity, the max is 3).

Trouble-Shooting

Here’s a common issue.  You want to use SSH keys to access your account and you’ve created your keys and you’ve transferred your public key to your remote account and created an authorized_keys file in the .ssh directory.  You’ve also checked your file permissions and you’re still getting prompted for a password.  I am using my account Garland to ssh into the same windows machine (using loop back address 127.0.0.1) into account wireshark.  Here’s a transcript from the SSHD server process running in debug mode:

 

The yellow text above shows that the authorized_key file is being processed, but you’re still getting the following:

A close look at the transcript from the debug file shows what looks like a key, but it also shows key not found.   Let’s take a look at the .ssh/authorized_keys file in the wireshark user directory

We should be able to read the key value.  Let’s take a look at the id_rsa.pub file that was created for user Garland (note: the entire key isn’t shown, but at least we can read this one).

So let’s recreate the authorized_keys file and check to insure it looks correct.

Here is an example of a successful interactive login from the sshd debug log.  The key is successfully processed and an interactive session is shown to have started at the end of the log.

The next screen shows and ssh from the client side; however, this time we just do a directory (non-interactive). Note: my local user account is Garland and the target account is user wireshark.  No password was required.

This is just a trivial example of resolving ssh issues.  The process demonstrated here-in is valid for more complex ssh issues.  You can also run the sshd server in debug to insure that your config file for sshd is configured correctly.

Comments are closed.