Home
Forum Home Forum Home > Other > Other
  New Posts New Posts RSS Feed - Pi 4 Batch file
  FAQ FAQ  Forum Search   Events   Register Register  Login Login


A Model 4 Hire Forum

Pi 4 Batch file

 Post Reply Post Reply
Author
Message
Admin View Drop Down
Admin Group
Admin Group


Joined: 23 May 2013
Status: Offline
Points: 469
Post Options Post Options   Thanks (0) Thanks(0)   Quote Admin Quote  Post ReplyReply Direct Link To This Post Topic: Pi 4 Batch file
    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.



Back to Top
Sponsored Links


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.06
Copyright ©2001-2023 Web Wiz Ltd.

This page was generated in 0.438 seconds.
eXTReMe Tracker