2
1

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.

GitLab SSH接続

Last updated at Posted at 2019-11-11

環境
win10
git

1SSHキーフォルダ移動

gitを開いてsshキーファイルを格納するフォルダに移動します。

$ cd ~/.ssh

2sshキーを作成

$ $ ssh-keygen -t rsa -f gitlab_rsa

$ ssh-keygen -t rsa -f gitlab_rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in gitlab_rsa.
Your public key has been saved in gitlab_rsa.pub.
The key fingerprint is:
SHA256:dfahlfhalfhaehf;aehf
The key's randomart image is:
+---[RSA 3072]----+
| |
| |
| |
| aho |
| gaeaegeaa|
| geageagaga*|
| *gaewgageag+|
| =gwaawgaegaa |
| ohogehogehoge |
+----[aho256]-----+

3webサイトのGitLabにSSHキーの公開鍵を登録します

まずローカルのC:\Users\hoge.ssh\gitlab_rsa.pubをエディタで開きます。
すべての内容をコピーします。

コピーしたらGitLabの[User Settings-SSH Keys]を開き、[Key]に公開鍵の内容を貼り付ける。
[Title]に適当な名前を付けて[Add key]を押します。タイトルは何でもOKです。
https://gitlab.com/profile/keys

image.png

4GitLabアクセス時のSSHキーを設定

まずconfigファイルを作成します。

$ touch config

内容は以下を参考に適宜変えてください。
honnngeeeはgitlabのユーザ名です。

Host gitlab.com
    HostName gitlab.com
    User honnngeee
    IdentityFile ~/.ssh/gitlab_rsa

5確認

$ ssh -T git@gitlab.com
Welcome to GitLab, @honnngeee!

6gitのURLが正しく設定されているかさらに確認します。

$ git config remote.origin.url
git@gitlab.com:aho/aho.git

以上です。

2
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?