Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# のアカウントを作成し、ログインする。
# Github用の公開鍵、秘密鍵を生成する。
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/matsumura/.ssh/id_rsa):
Created directory '/home/matsumura/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/matsumura/.ssh/id_rsa.
Your public key has been saved in /home/matsumura/.ssh/
# 公開鍵と秘密鍵の名前を分かりやすいものに変更する。
$ mv ~/.ssh/id_rsa ~/.ssh/github_id_rsa
$ mv ~/.ssh/ ~/.ssh/
$ chmod 600 ~/.ssh/github*
# Github用の公開鍵を使用する準備をする(サーバへのSSH接続の鍵と分けるため)。
$ vi ~/.ssh/config
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
# configファイルの権限を変更する。
$ chmod 600 ~/.ssh/config
# 生成した公開鍵の中身をコピーする。
$ cat ~/.ssh/
# Githubのアカウントに公開鍵を登録する。
[Account settings] -> [SSH Keys] -> [Add SSH Key]
# 接続できるかを確認する。
$ ssh
The authenticity of host ' (' can't be established.
RSA key fingerprint is (...鍵情報...).
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ',' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi tsubakimoto! You've successfully authenticated, but GitHub does not provide shell access.
Connection to closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment