2

First a screenshot that shows OpenSSH installed on Windows 10...

ssh

Above, I use the command ssh -V in the command prompt to make sure OpenSSH is installed.

Now.. It appears that throwing the following one liner into a .bat file to login to a linux server via ssh doesn't do anything.

ssh -p 22 root@10.10.1.100

When I type the same one liner into a windows 10 command prompt since Windows 10 now has OpenSSH built in, it logs me in just fine.

What I am missing?

suchislife
  • 4,251
  • 10
  • 47
  • 78
  • Didn't work. With your approach the prompt thinks `ssh` is the hostname argument. – suchislife Nov 08 '19 at 05:37
  • 1
    `C:\Windows\System32\OpenSSH\ssh.exe -p 22 root@10.10.1.100` – Gerhard Nov 08 '19 at 05:41
  • That works. So... is my answer below still appropriate or I should update with your solution since we aren't really focusing on PowerShell? – suchislife Nov 08 '19 at 05:45
  • You can leave you answer, I will post another one with my solution. – Gerhard Nov 08 '19 at 05:45
  • Ok. You know... just before it authenticates successfully every time, there is this `key_load_public: invalid format`. This doesn't show when I use PuTTY. I wonder if it's a windows thing... – suchislife Nov 08 '19 at 05:47
  • Did you setup public keys? if so, DSA or RSA? – Gerhard Nov 08 '19 at 05:49
  • Yeah. Then I use private key to connect and it works every time. It just... shows `key_load_public: invalid format`. – suchislife Nov 08 '19 at 05:50
  • 1
    Rather fix it properly. See the [link here](https://stackoverflow.com/questions/42863913/key-load-public-invalid-format) – Gerhard Nov 08 '19 at 05:57

1 Answers1

1

Firstly, do not name your batch file ssh.bat or ssh.cmd and it will probably be best if you use the full path to the executable:

@echo off
"C:\Windows\System32\OpenSSH\ssh.exe" -p 22 root@10.10.1.100
pause

but it is probably better to use the %windir% environment variable:

@echo off
"%windir%\System32\OpenSSH\ssh.exe" -p 22 root@10.10.1.100
pause
Gerhard
  • 22,678
  • 7
  • 27
  • 43