Windows SSH Commands to Rpi

So I am wondering if it is possible to send a command via SSH and get a return from a windows cmd session through PUTTY to a RPI.

What I am doing now is that i run a check IP from one Rpi to another Rpi and it return the IP address.
This works great on Linux because i have sshpass and it works flawless.

sudo -u openhabian sshpass -p MyPASSWORD123 ssh pi@ -p222 'sudo /bin/checkip'

Now that I am migrating my Rpi OpenHAB to Windows OpenHAB i am having a problem trying to get these remote SSH Commands working

Currently have tried:

var String results = executeCommandLine ("C:\\openHAB2\\conf\\scripts\\CheckIP.bat", 5000)

It start up putty and then closes it right away and does not return an address to my for CheckIP.bat

 "C:\Program Files\PuTTY\putty.exe" -ssh openhabian@ -pw "MYPASSWORD1234!" -m checkip

Does anyone have any experience with using CMD/Putty to return values from a session?

Thanks for any help!


i used :

"C:\Program Files\PuTTY\plink.exe" -ssh openhabian@ -pw "MYPASSWORD1234!" -m C:\openHAB2\conf\scripts\checkip.txt

And it now says:

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's ssh-ed25519 key fingerprint is:
ssh-ed25519 255 aa:4d:aa:a4:aa:31:68:a2:6b:aa:52:ae:67:6d
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
Store key in cache? (y/n) Connection abandoned.

Does anyone know how to input a y to accept the connection? When running this through command line I already accepted it and it is still asking to accept the connection.

Under Windows 10 you have now the possibility to activate the Linux Subsystem for Windows (WSL) - with that you would be able to use ssh commands from the command line without using Putty. Maybe that would help?

First, just try connecting to the server without everything from -pw onward. You should be able to press y. That will store the key in your registry and that won’t come up next time you run it. If that won’t work, connect using the PuTTY UI, accept the cert and then try the command from the shell.

In addition to the WSL, MS now provides a native version of openSSH which is handy if you want to use the VSCode Remote SSH extension (let’s you edit files on a remote machine through SSH). See Then you can use ssh from cmd or PowerShell like you are used to from Linux or Mac. The only limitation I’ve found with it so far is it doesn’t support ProxyCommand (i.e. you can’t tunnel through multiple SSH hops automatically).

Is that a global or per-user setting? If it is per-user, the OP will have to do it as the same user OpenHAB runs as.

Based on the OP, the user is running ssh from a Windows box to the openHAB box. There is no openhab user on the box the ssh is initiated from. The user on the Windows box is irrelevant and I assume it’s the user’s normal login. The command they are trying to run is using user openhabian which makes sense as you cannot ssh into the openhab user (nor should you be able to).

So running the command where you can pretty the y for the current user should be sufficient.

But to answer your question, it is per user, not global.

I read that as them running the ssh command from a rule, and now that it is on Windows, the ssh fails.

If openhab on Windows runs as an openhab user, that will be the user they need to log in as to hit ‘y’ on manually. I assumed they had done it as their usual account and the openhab user still needed approval.

Does openhab run as a different user on Windows? I don’t know.

I was looking at the actual command they are trying to run:

 "C:\Program Files\PuTTY\putty.exe" -ssh openhabian@ -pw "MYPASSWORD1234!" -m checkip

They are on the Windows machine and logging in to an openhabian machine.

To my knowledge, openHAB does not run as a different user on Windows.

Windows cmd promt can ssh by default simply by:

ssh openhabian@

Thats why the openhabian@IP is needed.Then it will promt for the pw for the openhabian user.

This must be a very recent addition to the default Windows 10 install. Until as recently as a few weeks ago I had to enable ssh support.

My Windows10 is professionel version. Perhaps ssh needs to be installed in home versions. But thats a small task to do wihtin a few seconds.

I only use Windows at work, it’s definitely a Pro version, but not on the latest and greatest patches from MS.

I cant tell… Maybe ssh is disabled from your policy at work? (at my work everything seems disabled)
I would assume ssh beeing installed by default on all pro windows 10. I dont see why it shouldn´t. It is a “pro” utility.

I have already accepted and hit y when running from commandline. It is only when it runs from the rule it asks to hit y to accept and shows that in the logs.

The SSH is an optional windows feature and you have to install it separately. The list of optional features includes an OpenSSH-Client (= ssh) and also en OpenSSH-Server.

Then Lou’s question comes into play. What user is openHAB running under on the Windows machine?

hmmmm… I wonder how I would get around that to try and apply that openhabian/openhab user to see if this will work.

You would not have an openhabian user on your Windows machine.

I don’t know how Windows manages openHAB as a service and whether the installation instructions have you create a new user to run it under or not. I don’t think it does meaning that I’d expect it to be running under your login name.

But if you’ve accepted the cert from your RPi from the command line, then it should be accepted for your login user whether or not it’s you at the command line or openHAB running. Maybe you need to restart openHAB after pressing “y” at the command prompt.

If he doesnt supply the username@IP when he connects through cmd promt, then it will use the windows username (default).

I dont recall ever having installed the SSH client.