I want to SSH to a Windows 2012 server. But I get "connection refused."

This topic contains 4 replies, has 3 voices, and was last updated by Profile photo of Kiran Kiran 3 months, 2 weeks ago.

  • Author
    Posts
  • #50086
    Profile photo of Kiran
    Kiran
    Participant

    I installed the 64 bit version of OpenSSH on a Windows Server 2012 machine. In PowerShell I started the SSH service. I could not SSH to the Windows server from the server itself. This is how I test SSH on Linux.

    I tried to SSH from a Linux server to the Windows server. I got the error "connection refused." I know that port 22 is not blocked from the Linux server to the Windows server. What do I need to do to get OpenSSH to work?

    I followed all of the github directions except the optional steps. What am I doing wrong?

  • #50089
    Profile photo of John_JHA
    John_JHA
    Participant

    Any entry in Windows server event/firewall logs about the dropped connection?

    Curious. Can you telnet (port 23) to it for test purposes?

  • #50250
    Profile photo of Kiran
    Kiran
    Participant

    I could not use Putty to get into the Windows server. I get "connection refused." Port 23 is not blocked between the Linux server and Windows server. I don't have any way of using telnet that I can think of. I saw nothing in the logs. No connection ever initiates.

  • #50260
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

    First get an SSH connection going from the Windows server itself. Do you see the OpenSSH server listening on port 22?

    PowerShell command:

    Get-NetTCPConnection | Where-Object { $_.LocalPort -eq 22 }
    

    PowerShell output:

    LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting OwningProcess 
    ------------                        --------- -------------                       ---------- -----       -------------- ------------- 
    ::                                  22        ::                                  0          Listen                     3564          
    0.0.0.0                             22        0.0.0.0                             0          Listen                     3564
    

    Command Prompt command:

    netstat -an -p tcp | findstr 0.0.0.0:22
    

    Command Prompt output:

      TCP    0.0.0.0:22             0.0.0.0:0              LISTENING
    
  • #50709
    Profile photo of Kiran
    Kiran
    Participant

    I eventually got it to work. I do not know the root cause.

You must be logged in to reply to this topic.