環境
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
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
以上です。