Print Page | Close Window

Pi 4 Batch file

Printed From: A Model 4 Hire
Category: Other
Forum Name: Other
Forum Description: Non related topics
URL: http://www.amodel4hire.co.uk/forum/forum_posts.asp?TID=178
Printed Date: 20 Apr 2024 at 00:34
Software Version: Web Wiz Forums 12.06 - https://www.webwizforums.com


Topic: Pi 4 Batch file
Posted By: Admin
Subject: Pi 4 Batch file
Date Posted: 07 Apr 2021 at 18:52
I was looking all over the internet for how to connect to my raspberry Pi 4 using a batch file. Most of the articles end up using Putty. Windows 10 has a built in ssh server which is what I wanted to use.

I found that there are a couple of methords to do this my first attempt was to create the batch file by creating a new text file and just renaming it with the extention .bat this worked when I had dos way back in the 80's
I knew if I put cmd /k in the file this would just open a new cmd window. So I was nearly there!

What I had to figure out was where was the ssh server this is where I found it in my computer C:\Windows\System32\OpenSSH\ssh.exe with a little help from various sources I found that

cmd /k C:\Windows\System32\OpenSSH\ssh.exe -p 22 pi@192.168.1.1

This opened and connected to my pi which then asked for my password bam your in.

what the code above does is goes to the directory runs ssh and connects user. The bits I have in bold are the bits you will need to change. Use your username@change 192.168.1.1 to the address you normally connect to you pi with.

other have said rather than use c:\windows you can use %windir% so this is how it would look
cmd /k "%windir%\System32\OpenSSH\ssh.exe" -p 22 pi@192.168.1.1

so to put it all together you can use either method it's up to you.

@ECHO OFF
ECHO Batch file to connect to PI server with ssh.
C:\Windows\System32\OpenSSH\ssh.exe -p 22
pi@192.168.1.1

Put the above code into you batch file and you are read to connect
Hope this has been of help.





-------------
Admin - Guido

http://www.amodel4hire.co.uk - http://www.amodel4hire.co.uk



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.06 - https://www.webwizforums.com
Copyright ©2001-2023 Web Wiz Ltd. - https://www.webwiz.net