MacBookAirを買ってやったこと githubの再登録編
MacBookAirが届いて、いろいろとやることがあったので、メモ。
ここでは公開鍵を作成してから、githubに登録するまで。
まずは公開鍵と秘密鍵を作成します。
$ ssh-keygen -t rsa -C "{githubに登録したメールアドレス}" Generating public/private rsa key pair. Enter file in which to save the key (/Users/{ユーザー名}/.ssh/id_rsa): {鍵の名前} Enter passphrase (empty for no passphrase): {パスワード入力} Enter same passphrase again: {もう一回同じパスワードを入力} Your identification has been saved in {鍵の名前}. Your public key has been saved in {鍵の名前}.pub. The key fingerprint is: 88:70:3f:0d:66:01:97:21:4c:d2:ae:e5:48:6e:13:2b {githubに登録したメールアドレス} The key's randomart image is: +--[ RSA 2048]----+ ここにランダムなイメージがながれます。 +-----------------+
ls で見ると鍵ができてます。
{鍵の名前}.pubが公開鍵で{鍵の名前}のファイルが秘密鍵です。
$ ls ~/.ssh known_hosts {鍵の名前} {鍵の名前}.pub
次に複数の公開鍵を管理するために、.ssh配下に設定ファイルconfigを作成します。
設定ファイル config の中身は
Host github.com User {githubのユーザー名} Hostname github.com PreferredAuthentications publickey IdentityFile {秘密鍵のファイルへの絶対パス}
次にgithubに公開鍵を登録しましょう。
最後にちゃんと登録されているか確認します。以下のように出力されればOKです。
初回アクセス時はパスワード入力が必要です。
$ ssh -T git@github.com Hi Vermee81! You've successfully authenticated, but GitHub does not provide shell access.
皆様に素敵なgithubライフがあらんことを。