LoginSignup
3
2

More than 5 years have passed since last update.

gitをwindowsで使用する場合にsshでcloneする方法

Posted at

bitbucketを用いてリポジトリを管理しているのだが少し躓いたのでメモしておく。
1. .sshディレクトリを C:\Users\userName\以下に作成する。(userNameは自分のホームディレクトリ)ここでドットが先頭に付くディレクトリは新規ディレクトリ作成で.ssh.と最後にドットを余分に付けることにより作成することができる。
2. configという名前でファイルを作成してそこに以下のように記述。

Host bitbucket.org
  IdentityFile C:\Users\userName\.ssh\id_rsa_bitbucket.ppk

(id_rsa_bitbucket.ppkは秘密鍵)
これで git clone git@bitbucket.org:hogehoge/hogehoge.git
などとやればリポジトリからファイルを取得することができる。結局ディレクトリの作成方法とPathの書き方以外はLinux/Macと同じである。

因みにうまくIdentityFileのPathが設定されていないとgit cloneした時に下記のようなエラーが表示された。

The authenticity of host 'bitbucket.org (2401:1d80:1010::152)' can't be established.
RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,2401:1d80:1010::152' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
3
2
2

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
3
2