LoginSignup
45

More than 5 years have passed since last update.

posted at

updated at

【GitLab】SSH接続をテストする

SSH接続をテストする

  • ちゃんと「SSH認証キー(公開鍵)」が登録されているのか?
  • ちゃんとSSH接続できるのか?

念の為、テストを行っておこう。

GitLab」との接続テストには、「Git Bash」を使う。

まず、

$ ssh-add -l

このコマンドで、既に「OpenSSHキー」が登録済みかどうかを確認する。

もしも以下のように「Could not open a connection to your authentication agent.」が出力されてしまったら、

$ ssh-add -l
Could not open a connection to your authentication agent.

以下のコマンドを実行してみよう。

$ eval `ssh-agent`
Agent pid 13132

Agent pid 13132」が出力されれば問題ない。

改めてコマンドを実行し、以下のように「The agent has no identities.」が表示されたら、「OpenSSHキー」はまだ登録されていないということになる。

$ ssh-add -l
The agent has no identities.

では、以下のコマンドを実行して、「OpenSSHキー」を登録しよう。

~/.ssh/」は、「ユーザのホームフォルダ」に作成した「.ssh」のことを指している。

$ ssh-add ~/.ssh/id_rsa_gitlab_cutboss
Identity added: /c/Users/cutboss/.ssh/id_rsa_gitlab_cutboss (/c/Users/cutboss/.ssh/id_rsa_gitlab_cutboss)

これで「OpenSSHキー」の登録が成功したので、以下のコマンドを実行して「GitLab」のSSH接続テストを行おう。

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

おー!

GitLab」に登録している私のユーザ名が表示された!

これで問題なく、「GitLab」とのSSH接続テストが成功した。

参考記事

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
What you can do with signing up
45