LoginSignup
4
3

More than 5 years have passed since last update.

Gitlabでssh接続をする方法

Posted at
  1. ssh-keygenで公開鍵と秘密鍵を作る

    ssh-keygen -t rsa -C "t.katou@gmail.com"
    
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/.ssh/id_rsa): gitlab_id__rsa[Enter]#なんでも大丈夫だけど、あとで使います。
    Enter passphrase (empty for no passphrase):    ← [Enter]必要であれば入力
    Enter same passphrase again:        ← [Enter]必要であれば入力
    
  2. 公開鍵をgitlabに登録する

    • gitlabのSettingsからSSH Keysを選び、以下のコマンドで公開鍵をコピーして、「key」欄にペーストして、「Add key」をクリック。「title」は変更しなくても大丈夫。
    公開鍵のコピー
    pbcopy < ~/.ssh/id_rsa.pub
    
  3. ~/.ssh/configを編集する

    ~/.ssh/config
    HOST 10.10.10.10
    user git
    HostName 10.10.10.10
    identitiesonly yes
    identityFile ~/.ssh/gitlab_id_rsa
    
  4. ssh接続を確認する

    ssh -T gitlabのホスト名(アドレス)
    Welcomek to Gitlab, Taro Katou!
    
4
3
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
3