blob: 64efe66eca2d4ff1a0d41c813781b41b80817133 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
function sheb() {
# if an address wasn't specified, use the ec2 command to select an instance
if [[ $# == "0" ]]; then
1=$(ec2 | fzf --no-multi --prompt="ec2 instance> " | sed 's/ .*//')
if [[ -z "$1" ]]; then
return 1
fi
fi
# first add key to agent if necessary
if [[ ! $(ssh-add -L) ]]; then
ssh-add -K ~/.ssh/id_rsa
fi
if [[ $(echo "$1" | grep "@") ]]; then
# If a username was provided, use it
ssh -J virtyx -t "$1" "sudo su -"
else
# Otherwise, assume username is "ec2-user"
ssh -J virtyx -t "ec2-user@$1" "sudo su -"
fi
}
|