1
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?

More than 1 year has passed since last update.

windows git bash ssh接続

Last updated at Posted at 2022-01-15

はじめ

リモートとやりとりするときにパスワード入力は面倒なのでssh通信しようと思ったとき皆もよく忘れる例の手順を適当に書く

てじゅん

git bash起動

.sshディレクトリを作成

$ mkdir .ssh

id_githubという鍵を生成

$ ssh-keygen -t id_github -C "your_emai@example.com"

SSHエージェントが起動してるか確認

$ eval "$(ssh-agent -s)" 

起動してたら、SSHエージェントに登録

$ ssh-add id_github

公開キーをコピー

$ clip < ~/.ssh/id_github.pub

GithubのSettings/SSH and GPG keysのAdd SSH keyをクリックして、コピーした公開キーを登録

登録がうまくいっていれば成功メッセージが返ってくる

$ ssh -T git@github.com
Hi youname! ... successfully ... access.

.sshフォルダのconfigファイルを作成

$ vim ~/.ssh/config

ここにはssh通信するときに設定ファイルの参照場所を書く

Host github
    HostName github.com
    IdentityFile ~/.ssh/id_github
    User git

git pushしてうまくいくか試す

$ git push
1
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
1
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?