Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cygwin ssh shortcut from windows desktop

I have multiple servers that I need to remote into. I prefer Cygwin over Putty to do so.

Anyhows - the process of opening my cool Mintty window and then typing the following commands takes too long. PS - I am using a "key" authentication to these servers.

First, I double Click Cygwin Terminal shortcut from my windows desktop.

Then once the terminal session has booted up, from the command prompt I type the following -

$ eval `ssh-agent`
$ ssh-add
$ ssh <username>@<servername>

Please keep in mind that my 'servername' is variable. In fact I have about 10 different server names that could potentially be inserted there - Hence my need for 10 different shortcuts. I would prefer to double click on something from my desktop that will fire up my Mintty and automatically execute the above bash shell commands.

Does anyone have or can recommend a nice/elegant solution to do this?

(I have a feeling that it has something to do with the Target attribute of the Windows short-cut icon that I am clicking on.)

like image 719
ivan_drago Avatar asked Aug 30 '12 22:08

ivan_drago


1 Answers

You can do this without too much difficulty. Copy the existing Cygwin Terminal icon, right click on it, and select Properties. You should see something like the below in the Target field:

C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -

Replace this with the following (replacing <username> and <servername> as relevant):

C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/bash -l -c "eval `ssh-agent` ; ssh-add ; ssh <username>@<servername>"

Repeat as necessary for your other servers. That's it!

(Detail: We replace the - argument [which means to use the standard login shell] with an explicit call to bash to run your commands. The -l part means to use a login shell, which in particular means your PATH variable is set up and so bash can find ssh. The -c part just introduces the command, which you should recognize from your question.)

like image 121
me_and Avatar answered Nov 14 '22 10:11

me_and