Friday, May 9, 2014

Shell script that Prompts to Automatically Connect via SSH using .bash_profile in Cygwin

I wanted my cygwin terminal to automatically prompts me to login via SSH or to cancel and use local bash for whatever on my local machine. I found out the .bash_profile automatically runs on login so I made it call a external shell script with ./ to prompt for the two options of logging in by SSH or exiting the prompt and using cygwin's local bash environment.

Here is the code for :

   2  echo "Connect SSH?"
   3  select yn in "Yes" "No"; do
   4      case $yn in
   5          Yes ) ssh user@server; break;;
   6          No ) exit;;
   7      esac
   8  done

Then update your .bash_profile with the line 


Thats all you need to do.

No comments:

Post a Comment