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?

GitHubにSSHkeyでpushする最速メモ

Posted at

SSH キーの登録まで

名前を id_ed25519_github にしました。
まずは鍵を生成します。

$ cd ~/.ssh
$ ssh-keygen -t ed25519
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/wsl/.ssh/id_ed25519): id_ed25519_github
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_ed25519_github
Your public key has been saved in id_ed25519_github.pub

$ cat ~/.ssh/id_ed25519_github.pub
ssh-ed25519 xxxxxxxxxxxxxxxxxxxxxxx wsl@DESKTOP-XXXXXXX

この ssh-ed25519 xxxxxxxxxxxxxxxxxxxxxxx wsl@DESKTOP-XXXXXXX をコピーします。

以下のページの SSH Keys に登録します。

image.png

image.png

そしたら鍵とドメインを紐づけて GitHub の時はこの鍵を使うようにします。

~/.ssh/config
Host github.com
  HostName github.com
  User git
  Port 22
  IdentityFile ~/.ssh/id_ed25519_github
  TCPKeepAlive yes
  IdentitiesOnly yes

動作確認。

$ ssh -T git@github.com
Hi xxxxxx! You've successfully authenticated, but GitHub does not provide shell access.

Shell にはアクセスできないが SSH とな?

git push まで

リポジトリに GitHub を登録する。

$ git remote add origin git@github.com:<user-name>/<project-name>.git
$ git branch -M main
$ git push -u origin main

$ git push --all origin
$ git push --tags

もし origin が登録済みと出たら、

$ git remote rm origin

ん~もっと簡単になってほしい気持ち。

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?