Last active
April 30, 2024 22:24
-
-
Save atr0s/70d2c7327a3d1520d58998adc620fa5b to your computer and use it in GitHub Desktop.
Revisions
-
atr0s revised this gist
Aug 13, 2019 . No changes.There are no files selected for viewing
-
atr0s revised this gist
Aug 13, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ function aws-ssm-menu { function aws-scp { if [ "$#" -lt 2 ]; then echo "Usage: aws-scp <profile name> <scp parameters>" else scp -o ProxyCommand="bash -c \"aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p' --profile $1\"" ${@:2} fi -
atr0s revised this gist
Aug 13, 2019 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,6 +30,14 @@ function aws-ssm-menu { fi } function aws-scp { if [ "$#" -lt 2 ]; then echo "Usage: aws-scp <profile name> <ssh parameters>" else scp -o ProxyCommand="bash -c \"aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p' --profile $1\"" ${@:2} fi } function aws-ssh { if [ "$#" -lt 2 ]; then echo "Usage: aws-ssh <profile name> <ssh parameters>" -
atr0s revised this gist
Aug 12, 2019 . 1 changed file with 53 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,61 @@ # Snippet of code to be put on ~/.bash_profile to help SSH into instances via Session Manager while specifying AWS profiles # It can be used by saving ~/.ssm_bash_profile and adding the following line to ~/.bash_profile # source ~/.ssm_bash_profile function aws-ssm-instance-list { if [ "$#" -lt 1 ]; then echo "Usage: aws-ssm-instance-list <profile name>" else output=$(aws ssm describe-instance-information --profile $1 --query "InstanceInformationList[*].{Name:ComputerName,Id:InstanceId,IPAddress:IPAddress}" --output text) echo "$output" fi } function aws-ssm-menu { printf "List of instances for $1:\n\n" instance_list_output=$(aws-ssm-instance-list $1) IFS=$'\n' instance_list=($instance_list_output) unset IFS for i in "${!instance_list[@]}"; do printf "%s) %s\n" "$i" "${instance_list[$i]}" done printf "\nSelect an instance from the list above: " IFS= read -r opt if [[ $opt =~ ^[0-9]+$ ]] && (( (opt >= 0) && (opt < "${#instance_list[@]}") )); then return $opt else printf 'invalid option\n' return -1 fi } function aws-ssh { if [ "$#" -lt 2 ]; then echo "Usage: aws-ssh <profile name> <ssh parameters>" else ssh ${@:2} -o ProxyCommand="bash -c \"aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p' --profile $1\"" fi } function aws-ssm-session { if [ "$#" -lt 2 ]; then echo "Usage: aws-ssm-session <profile name> <instance_id>" else aws ssm start-session --target $2 --profile $1 fi } function aws-session-interactive { if [ "$#" -lt 1 ]; then echo "Usage: aws-ssh-interactive <profile name>" else aws-ssm-menu $1 choice=$? if [ $choice -ne 255 ] ; then instance_id=$(echo "${instance_list[$choice]}"| awk {'print $2'}) aws-ssm-session $1 $instance_id fi fi } -
atr0s revised this gist
Aug 7, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,6 @@ function aws-ssh { if [ "$#" -lt 2 ]; then echo "Usage: aws-ssh <profile name> <ssh parameters>" else ssh ${@:2} -o ProxyCommand="bash -c \"aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p' --profile $1\"" fi } -
atr0s revised this gist
Aug 7, 2019 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,5 @@ function aws-ssh { echo "Usage: aws-ssh <profile name> <ssh parameters>" else ssh ${@:2:99} -o ProxyCommand="bash -c \"aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p' --profile $1\"" fi } -
atr0s created this gist
Aug 7, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ # Snippet of code to be put on ~/.bash_profile to help SSH into instances via Session Manager while specifying AWS profiles # function aws-ssh { if [ "$#" -lt 2 ]; then echo "Usage: aws-ssh <profile name> <ssh parameters>" else ssh ${@:2:99} -o ProxyCommand="bash -c \"aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p' --profile $1\"" fi }