9
11

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.

GitHubでSSH接続するときPermission deniedと言われる

Posted at

起こったこと

GitHubだから云々というわけではないけど
リモートリポジトリにプッシュしようとしたところ以下のメッセージが出た

$ git push origin filling-in-layout
The authenticity of host 'github.com (192.30.255.112)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/Users/xxxxxxxxxxxx/.ssh/known_hosts).
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

(今までこんなの出たかったんだけどな、、、AWSいじってみた時に何かやらかしたのかな、、、)

GitHubとのSSH接続の確認のために以下も実施してみるも同様のメッセージ
(ただ、IPが違う??)

$ ssh github.com
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/Users/xxxxxxxxxx/.ssh/known_hosts).
xxxxxxxxxxx@github.com: Permission denied (publickey).

とりあえず「権限がないよ〜」とのことなので、
色々ググった結果「id_rsa」の権限でコケることがあるよとのこと
ふむふむ

$ sudo ls -al ~/.ssh
total 32
-rw-r--r--   1 xxxxxxxxxx  staff   223 12 29 19:43 config
-rw-------   1 xxxxxxxxxx  staff  1766  2 26  2018 id_rsa
-rw-r--r--   1 xxxxxxxxxx  staff   409  2 26  2018 id_rsa.pub
-rw-------   1 xxxxxxxxxx  staff     0 12 29 19:39 known_hosts

いけてそうだぞ??

ってことは「~/.ssh」自体の権限が違うんじゃね??

dr--------    7 xxxxxxxxx  staff    224 12 29 19:43 .ssh

怪しい
ググる→権限変更の必要ありそう

$ sudo chmod 700 ~/.ssh
$ sudo ls -al ~
drwx------    7 xxxxxxxxxx  staff    224 12 29 19:43 .ssh

完了
どうだ!?

$ ssh -T git@github.com
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
+---[xxxxxxxx]----+
| xxxxxxxxxxx     |
|xxxxxxxxxxx      |
|xxxxxxxxx        |
|xxxxxxxxxxxx     |
|xxxxxxxxxxx      |
|xxxxxxxxxxxx     |
|xxxxxxxxx        |
| x     x         |
|                 |
+----[xxxxxx]-----+
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.
Hi esaki11! You've successfully authenticated, but GitHub does not provide shell access.

いけた!

9
11
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
9
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?