4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

peco とjqを使ってaws へのSSHを楽にする

4
Posted at

EC2インスタンスへアクセスするsshの鍵(~/.ssh/)とホストのタグ名をpecoで選択してec2-userでログインする
VPC前提なので、GIPで直接SSHの場合は要修正


function awsssh(){
  SSH_TARGET_HOST="$(aws ec2 describe-instances|jq -r '.Reservations[].Instances[].Tags[].Value'|peco)"
  ssh -i ~/.ssh/"$( ls ~/.ssh/ |peco)" ec2-user@"$(aws ec2 describe-instances|jq -r --arg SSH_TARGET_HOST $SSH_TARGET_HOST '.Reservations[].Instances[]|select(.Tags[].Value == $SSH_TARGET_HOST )|.PrivateIpAddress'|peco)"
}
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?