LoginSignup
4
4

More than 5 years have passed since last update.

ec2ssh update 時に自動で ssh option を入れる。もしくは GitHub からブランチを指定して gem install する方法。

Last updated at Posted at 2013-10-03

ec2ssh という素晴らしい gem があります。https://github.com/mirakui/ec2ssh
とても便利なのですが、ec2ssh update 後に、毎回 User とか IdentityFile を編集するのが若干面倒だったり…

これを自動で入れてくれるようにするプルリクが出ているのですが、5ヶ月前から放置されているという悲しい状態です… ( https://github.com/mirakui/ec2ssh/pull/11 )

ということで、対処療法的に GitHub から直接 gem をインストールして、この便利オプションを使えるようにしたというお話。

※上記 Pull Request が merge されたので、以下の specific_install は必要なくなりました

GitHub から直接 gem install できるようにする

gem 自体には、URL を指定して gem install する方法がないようなので、 https://github.com/rdp/specific_install この gem を導入します。

$ gem i specific_install

その後、ssh_options が有効になったバージョンの ec2ssh をインストールします。

$ gem uninstall ec2ssh # 既存のは消しておく
$ gem specific_install https://github.com/frsyuki/ec2ssh.git ssh_options

specific_install の細かいオプションは GitHub を見て下さい。

ec2ssh update 時に ssh option が入るようにする

上記と同じようにインストールした場合、~/.ec2ssh を以下のように編集します。

~/.ec2ssh
---
path: "/path/to/ssh/config"
aws_keys:
  default:
    access_key_id: foo
    secret_access_key: bar
regions:
- ap-northeast-1
ssh_options:
  - "IdentityFile /path/to/identity/file"
  - "User ec2-user"

これで ec2ssh update するとこんな感じになります。

### EC2SSH BEGIN ###
# Generated by ec2ssh http://github.com/mirakui/ec2ssh
# DO NOT edit this block!
# Updated 2013-10-03T20:33:42+09:00

# section: default
Host hoge
  HostName fuga
  IdentityFile /path/to/identity/file
  User ec2-user


### EC2SSH END ###

便利!

4
4
2

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