Help us understand the problem. What is going on with this article?

ターミナルからgithubのリポジトリにアクセスする設定(sshの設定)

More than 5 years have passed since last update.

GitHub Helpページを参考にしてます。
https://help.github.com/articles/generating-ssh-keys

まず、鍵を作成。鍵のファイル名はgithub_id_rsaにしています。

$ cd ~/.ssh/
$ ssh-keygen -t rsa -C "メールアドレス"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/ユーザー名/.ssh/id_rsa): github_id_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in github_id_rsa.
Your public key has been saved in github_id_rsa.pub.
(省略)

クリップボードに公開鍵をコピー。pbcopyコマンドでコピーします。

$ pbcopy < github_id_rsa.pub

GitHub Webページの「User settings」「SSH Key」へ。
「Add SSH key」に進んでクリップボートにコピーした公開鍵を貼り付けます。

これで設定完了です。
ターミナルのsshコマンドで接続確認を行います。

$ ssh -l git -i ~/.ssh/github_id_rsa github.com                                                       
PTY allocation request failed on channel 0
Hi pakiln! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

接続できました。

次はおまけです。sshコマンドのオプションを省略する設定です。

$ vi ~/.ssh/config
Host github.com
 HostName      github.com
 IdentityFile  ~/.ssh/github_id_rsa
 User          git

この設定をしておくと、

$ ssh github.com

$ ssh -l git -i ~/.ssh/github_id_rsa github.com                                                       

を実行したことになります。

pakiln
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした