suchislife
suchislife

Reputation: 1

BATCH file to connect to Linux via SSH. How?

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 [email protected]

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?

Upvotes: 2

Views: 8962

Answers (1)

user7818749
user7818749

Reputation:

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 [email protected]
pause

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

@echo off
"%windir%\System32\OpenSSH\ssh.exe" -p 22 [email protected]
pause

Upvotes: 1

Related Questions