0
0

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.

conohaのVPS上からgitlab.comのssh key登録がPermission denied (publickey)される

Last updated at Posted at 2017-02-08

#ユースケース
gitlab.comからconohaサーバーの方にリポジトリをcloneしたい時.(プロジェクトのデプロイ時など)
cloneするためにサーバーの公開鍵をgitlab.comに登録して、basic認証をしなくて良くしたい時.

#これでだめだった.
リモートで以下のコマンドを実行
$ssh-keygen -t rsa
$cat ~/.ssh/xxx.pub
この公開鍵をSSH KEYとして登録した後、
ssh -T git@gitlab.com
で登録した公開鍵でgitlabにアクセスしようとした時にPermission denied (publickey)される件です.

#解決策

(https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#generating-a-new-ssh-key)
これに従う

#結果
$eval "$(ssh-agent -s)"
$ssh-add ~/.ssh/xxx
注意していただきたいのが、2つめのコマンドで秘密鍵を自身のリストに登録しているところです.

そして
$ssh -T git@gitlab.com
でwelcomeと表示されると完了です.

#原因

$ssh -vT git@gitlab.com
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
:
:
debug1: Next authentication method: publickey
debug1: Trying private key: /home/user/.ssh/id_rsa
debug1: Trying private key: /home/user/.ssh/id_dsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Trying private key: /home/user/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

conohaのubuntuイメージでは~/.ssh/フォルダ内にデフォルトでid_rsaのファイルが生成されないため、デフォルト値を読みに行ってもファイルが無いためdenyされます.

#追記
2017/2/20

$cp ~/.ssh/xxx ~/.ssh/id_rsa

でコピーして作っちゃえばすべて解決します.

0
0
2

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?