99#
1010
1111scriptname=" aws-ssh"
12- scriptbuildnum=" 0.9.2 "
13- scriptbuilddate=" 2017-03-13 "
12+ scriptbuildnum=" 0.9.3 "
13+ scriptbuilddate=" 2017-03-20 "
1414
1515# ###########################################################
1616# ## PRE-EXECUTION
1717
1818# TURN ON COLOR IF POSSIBLE, SET THEME
1919if test -t 1; then # check if stdout is a terminal
2020 ncolors=$( tput colors) # see if it supports colors
21- if test -n " $ncolors " && test $ncolors -ge 8; then
21+ if test -n " $ncolors " && test " $ncolors " -ge 8; then
2222 # Set Colors
2323 bold=" $( tput bold) "
2424 underline=" $( tput smul) "
@@ -59,8 +59,8 @@ display_help_text() {
5959 echo -e " ${CLRtitle} USAGE: ${CLRnormal}${scriptname} ${CLRtitle2} instance-name [-n] [-u login-user] [-d] [-V] [-h]${CLRnormal} \n"
6060 echo -e " ${CLRtitle} \tOPTIONS:${CLRnormal} "
6161 echo -e " ${CLRtitle2} instance-name\t${CLRnormal} : (REQUIRED) name tag assigned to the EC2 instance"
62- echo -e " ${CLRtitle2} -n\t${CLRnormal} : Don't use PEM key while connecting ${CLRsuccess} *${CLRnormal} "
6362 echo -e " ${CLRtitle2} -u login-user\t${CLRnormal} : (optional) manually specify a login-username for ssh"
63+ echo -e " ${CLRtitle2} -n\t${CLRnormal} : Don't use PEM key while connecting ${CLRsuccess} *${CLRnormal} "
6464 echo -e " ${CLRtitle2} -d\t${CLRnormal} : debug mode"
6565 echo -e " ${CLRtitle2} -V\t${CLRnormal} : display version info"
6666 echo -e " ${CLRtitle2} -h\t${CLRnormal} : display help info"
@@ -74,7 +74,7 @@ DetermineLoginUser() {
7474 # Calculate the LoginUsername by determining the image running on the instance
7575
7676 # Get AMI-ID for Instance Specified by Name
77- ImageAMI=$( aws ec2 describe-instances --filters " Name=tag:Name,Values=${InstanceName} " --query ' Reservations[*].Instances[].[ImageId]' --output text)
77+ ImageAMI=( $( aws ec2 describe-instances --filters " Name=tag:Name,Values=${InstanceName} " --query ' Reservations[*].Instances[].[ImageId]' --output text) )
7878 # Get AMI description for AMI-ID which contains image type info
7979 ImageDescription=$( aws ec2 describe-images --image-ids " ${ImageAMI} " --query ' Images[*].{Name:Name}' --output text)
8080 case $ImageDescription in
@@ -124,7 +124,7 @@ if [ -z "$InstanceAddy" ]; then
124124 exit 1
125125fi
126126
127- if [ -z $UserLoginName ]; then
127+ if [ -z " $UserLoginName " ]; then
128128 DetermineLoginUser
129129else
130130 [[ " $debugmode " ]] && echo -e " LoginUser set by user: ${CLRtitle} $UserLoginName ${CLRnormal} \n"
134134if [[ " $nopem " ]]; then
135135 [[ ! " $debugmode " ]] && echo -e " ${CLRheading2} No PEM mode${CLRnormal} - connecting without PEM key\n"
136136 [[ " $debugmode " ]] && echo -e " ${CLRheading2} No PEM mode${CLRnormal} Connect string: ${CLRtitle} ssh ${LoginUser} @${InstanceAddy}${CLRnormal} \n"
137- ssh ${LoginUser} @${InstanceAddy}
137+ ssh " ${LoginUser} @${InstanceAddy} "
138138 exit 0
139139else
140140 [[ " $debugmode " ]] && echo -e " Connect string: ${CLRtitle} ssh -i ${HOME} /.aws/${InstanceKey} .pem ${LoginUser} @${InstanceAddy}${CLRnormal} \n"
0 commit comments