Test A SSH Connection from Windows commandline

19,683

Putty has a command line mode. Probably would work, but I'm not positive.

You could also use Nmap to check if the port is accepting connections.

Share:
19,683

Related videos on Youtube

IguanaMinstrel
Author by

IguanaMinstrel

Updated on September 18, 2022

Comments

  • IguanaMinstrel
    IguanaMinstrel over 1 year

    I am looking for a way to test if a SSH server is available from a Windows host. I found this one-liner, but it requires the a Unix/Linux host:

    ssh -q -o "BatchMode=yes" user@host "echo 2>&1" && echo "UP" || echo "DOWN"
    

    Telnet'ing to port 22 works, but that's not really scriptable. I have also played around with Plink, but I haven't found a way to get the functionality of the one-liner above.

    Does anyone know Plink enough to make this work? Are there any other windows based tools that would work?

    Please note that the SSH servers in question are behind a corporate firewall and are NOT internet accessible.


    Arrrg. Figured it out:

    C:\>plink -batch -v user@host
    Looking up host "host"
    Connecting to 10.10.10.10 port 22
    We claim version: SSH-2.0-PuTTY_Release_0.62
    Server version: SSH-2.0-OpenSSH_4.7p1-hpn12v17_q1.217
    Using SSH protocol version 2
    Server supports delayed compression; will try this later
    Doing Diffie-Hellman group exchange
    Doing Diffie-Hellman key exchange with hash SHA-256
    Host key fingerprint is:
    ssh-rsa 1024 aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa
    Initialised AES-256 SDCTR client->server encryption
    Initialised HMAC-SHA1 client->server MAC algorithm
    Initialised AES-256 SDCTR server->client encryption
    Initialised HMAC-SHA1 server->client MAC algorithm
    Using username "user".
    Using SSPI from SECUR32.DLL
    Attempting GSSAPI authentication
    GSSAPI authentication initialised
    GSSAPI authentication initialised
    GSSAPI authentication loop finished OK
    Attempting keyboard-interactive authentication
    Disconnected: Unable to authenticate
    
    C:\>
    
    • mdpc
      mdpc almost 11 years
      If ssh is up on a windows host the output should be about the same. What makes you think that Windows would handle the protocol differently?