Created
March 26, 2018 18:13
-
-
Save drbh/d65cdd2f769e95aca1f625fa4441c1a1 to your computer and use it in GitHub Desktop.
Easy way to add an alias to bash profile
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 characters
| #!/bin/bash | |
| echo 'Lets add a new SSH alias\n\n' | |
| read -n 1 -s -r -p "[Press any key to continue]" | |
| echo '\n\n' | |
| echo 'Alias Name (my ssh)' | |
| read aliasname | |
| echo 'Username (OS specific. eg Ubuntu:ubuntu AmazonLinux:ec2-user)' | |
| read username | |
| echo 'Host-name (address eg. ec2-35-182-252-128.ca-central-1.compute.amazonaws.com)' | |
| read host | |
| echo 'Key Location (path eg. ~/Keys/your-key.pem)' | |
| read key | |
| chmod 400 $key | |
| echo alias $aliasname=\"ssh -i $key $username@$host\"| cat - ~/.bash_profile > temp && mv temp ~/.bash_profile | |
| echo 'ADDED: ' alias $aliasname="ssh -i $key $username@$hostssh -i $key $username@$host" | |
| echo '\n[ COMPLETED ]\n\nPlese run \nsource ~/.bash_profile \nto activate your new alias\n\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment