LoginSignup
0
1

More than 5 years have passed since last update.

SSHメモ

Last updated at Posted at 2016-07-22

configファイルで複数SSH接続を管理

会社のgithubと自分のgithubを同じマシンで管理

  1. ssh configファイル自分のgithub接続用の設定追加

    config
    Host github_private
      User git
      Port 22
      HostName github.com
      IdentityFile ~/.ssh/github/private/id_rsa
      TCPKeepAlive yes
      IdentitiesOnly yes
    
  2. git origin追加、ホスト名をgithub_privateをする

    $ git remote add origin github_private:#{user-name}/xxxx.git
    

踏み台サーバー

  1. 踏み台サーバー経由

    shell
    Host bastion
      HostName bastion.test.com
      User test
      Port 22
      IdentityFile ~/.ssh/test/id_rsa
      ForwardAgent yes
    Host *.ap-northeast*
      ProxyCommand ssh bastion -W %h:%p
    

AWSのEC2サーバー管理

ec2ssh gemを使う
https://github.com/mirakui/ec2ssh

キーの管理

ssh-add

  1. 秘密キー作成して追加

    shell
    $ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    $ ssh-add ~/.ssh/id_rsa
    
  2. 秘密鍵の登録状況の確認

    shell
    $ ssh-add -l
    
  3. キーチェーンへ登録

    shell
    $ ssh-add -K ~/.ssh/test/id_rsa
    
  4. 再起動したら、キーチェーンから登録済みのキーを追加

    shell
    $ ssh-add -A
    
0
1
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
0
1