bash-3.2$ cd ~/.ssh
# 公開鍵と秘密鍵を作成します。
bash-3.2$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xxxxx/.ssh/id_rsa): id_rsa_github ←鍵の名前
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
#秘密鍵(id_rsa_github)と公開鍵(id_rsa_github.pub)が作成されていることを確認します。
bash-3.2$ ls -l
-rw------- 1 xxxxx staff 1831 2 7 08:20 id_rsa_github
-rw-r--r-- 1 xxxxx staff 408 2 7 08:20 id_rsa_github.pub
2.Githubへ公開鍵を登録
githubへログオン後、[Settings]から[SSH and GPG keys]を選択して、[New SSH Key]をクリックします。
bash-3.2$ vi ~/.ssh/config
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_github
User git
最後にsshで接続してみます。こんな感じで「Hi 〇〇〇!」と表示されたら成功です。
bash-3.2$ ssh -T github.com
Warning: Permanently added the RSA host key for IP address 'xxx.xxx.xxx' to the list of known hosts.
Hi gogoloon! You've successfully authenticated, but GitHub does not provide shell access.
コメント