Automate Git Bash

Connect to Linux machine

How to connect to a linux machine from a git bash terminal on Windows 7 machine.
Git bash is already a batch command executed from the dos command prompt.
So if you want to execute a linux shell script such as

"connect_to_jc.sh"

, then you need to create a batch file that will start a git bash terminal and then execute this shell script.

First create a shell script that looks like as follows

export DISPLAY=localhost:0.0
ssh -X -p <port_number>  -i <location_of_the_private_key>  <user@server>

The above shell script will set the display to forward X11 and use the private key to connect to the linux machine.

Now create the batch file

C:\Windows\System32\cmd.exe /c ""C:\Program Files (x86)\Git\bin\sh.exe" --login -i -- C:\Projects\connect_to_jc.sh"
Posted in Uncategorized

Comments are closed.