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 1 year has passed since last update.

公開鍵の登録までしたのにssh接続できない(ssh/configの設定ミス)

Posted at

結論

  • ssh/configのIdentityFileの欄は~/.ssh/を含めて書こう
  • エラー内容を読んでうなろう

概要

githubに接続しようと思って秘密鍵と公開鍵を作りました。
githubに作った公開鍵を登録しました。
現時点で以下のような状態になっています。

└── ~/
    └── .ssh/
        ├── config
        ├── id_rsa_github
        └── id_rsa_github.pub

ssh/configを以下のように登録しました。

~/.ssh/config
Host github
    HostName github.com
    User git
    IdentityFile id_rsa_github
    IdentitiesOnly yes

その場でssh githubすると……

user@laptop:~/.ssh/$ ssh github
PTY allocation request failed on channel 0
Hi ko-fnks! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

おおつながった。


作業ディレクトリに移ってgit push しようとすると

user@laptop:~/code/$ ssh github
no such identity: id_rsa_github: No such file or directory
git@github.com: Permission denied (publickey).

ニョ~~(声にならない音)

対処法

IdentityFileの記入の仕方を修正しました。

~/.ssh/config
Host github
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_github #ここの行をミスっていた。そらつながりませんわ。
    IdentitiesOnly yes
0
0
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
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?