質問するログイン新規登録

Q&A

解決済

1回答

16165閲覧

【助けて下さい><】gitにssh接続が出来ない(sourcetree)

choitarou

総合スコア112

SourceTree

SourceTreeは、Gitのクライアントツール。視覚的に操作するGUI形式でGitの操作が容易になります。MacやWindowsなどのOSに依存しておらず、PC環境に合わせてインストールすることが可能です。

Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

0グッド

1クリップ

投稿2016/10/16 05:26

0

1

お世話になっております。
今回はgitへのssh接続で質問させて下さい。

■環境
Windows 8.1
SourceTree 1.9.6.1
git 2.8.1.windows.1

■質問内容
gitへssh接続が出来ません。原因がさっぱり分からない為、
原因に心当たりがございましたらご教授頂きたいです。

■現象
・SorceTreeでcloneしようとすると以下のエラーが出ています。

warning: templates not found C:\Users\XXXXX\AppData\Local\Atlassian\SourceTree\git_local\share\git-core\templates Unable to open connection: Host does not existfatal: Could not read from remote repository.

・SorceTreeのターミナルからcloneした場合

ssh: Could not resolve hostname github: Name or service not known fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

・ssh接続の確認

$ ssh -vT git@github.com OpenSSH_7.1p2, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /c/Users/XXXXX/.ssh/config debug1: /c/Users/XXXXX/.ssh/config line 1: Applying options for github.com debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to github.com [192.30.253.113] port 22. debug1: Connection established. debug1: identity file /c/Users/XXXXX/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/XXXXX/.ssh/id_rsa-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.1 debug1: Remote protocol version 2.0, remote software version libssh-0.7.0 debug1: no match: libssh-0.7.0 debug1: Authenticating to github.com:22 as 'git' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ssh-rsa SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx debug1: Host 'github.com' is known and matches the RSA host key. debug1: Found key in /c/Users/XXXXX/.ssh/known_hosts:1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /c/Users/XXXXX/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 149 Enter passphrase for key '/c/Users/XXXXX/.ssh/id_rsa': debug1: No more authentication methods to try. Permission denied (publickey).

■鍵作成方法
鍵はSorcetreeの「SSHキーの作成/インポート」から秘密鍵(id_rsa)と公開鍵(id_rsa.pub)を作成し、
githubに公開鍵を登録、自PCのpagentに秘密鍵(id_rsa.ppk)を登録しました。
※id_rsa.ppkはid_rsaをコピーして作成しpagentに登録。

■pagentに表示されている内容

ssh-rsa 1024 YY:YY:YY:YY:YY:YY:(以下省略)

■githubのsetting⇒SSH and GPG Keysに登録した内容(pagentと一致しています)

ssh-rsa 1024 YY:YY:YY:YY:YY:YY:(以下省略)

■鍵の場所
Windowsなので、コマンドプロンプトからmkdir .sshにてディレクトリを作成。
C:\Users\XXXXX.sshに、id_rsa、id_rsa.pub、id_rsa.ppkを配置

■configファイル
C:\Users\XXXXX.sshに「config」ファイルを作成。内容は以下です。

Host github.com User git Port 22 Hostname github.com IdentityFile ~/.ssh/id_rsa TCPKeepAlive yes IdentitiesOnly yes

■known_hosts(SSH接続初回時にC:\Users\XXXXX.sshに作成されました。)

github.com,192.30.253.113 ssh-rsa ZZZZZ(以下省略) 192.30.253.112 ssh-rsa ZZZZZ(以下省略)

■その他気になる事
自分で調べている際、とあるHPには以下のレジストにファイルがないとダメという記事が
ありました。

HKEY_CURRENT_USER\SoftWare\SimonTatham\PuTTY\SshHostKeys ・rsa2@22:bitbucket.orgがないとSSH接続できないらしい。

確認したところでは、SimonTathamというフォルダがそもそもない状態です。
そこで、以下のコマンドを.sshのディレクトリから打つと、以下のような
結果となり、登録できませんでした。

XXXXX@JPCBBBBBB MINGW32 ~/.ssh $ "C:\Program Files (x86)\Atlassian\SourceTree\tools\putty\plink.exe" -ssh -C -i "id_rsa.ppk" git@github.com Hi GitHubアカウント名! You've successfully authenticated, but GitHub does not provide shell access. Using username "git". Server refused to allocate pty

いまの状況はこのような形です。本当は会社ではプロキシがありますが、いまは家でプロキシがない状態で
確認しています。まずはプロキシがない状態でssh接続ができるところまで設定したいのですが、
昨日からまったく進捗がないので、質問させて下さい。不足な情報は随時記載を追記していきますので、
ご教授のほど宜しくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

Bakudankun

2016/10/16 12:38 編集

まず、「SorceTreeのターミナルからcloneした場合」で「githubなど知らん(`.com`が抜けている)」と怒られていますが、ちゃんと`git@github.com:USERNAME/REPONAME.git`でcloneしていますか? その上で同じエラーが出ますか? (いずれにせよppk形式の秘密鍵はOpenSSHで使えなかったと思うので無駄な気がしますが一応)
choitarou

2016/10/16 13:52

ご回答ありがとうございます。上記の`git@github.com:USERNAME/REPONAME.git`形式で実施しても結果は同じでした。ssh -vT git@github.comがまず通っていないため、なぜそこが通らないのか不明な状況です。
choitarou

2016/10/16 13:57

公開鍵と秘密鍵は、SourceTreeからPutty Key Generatorを呼び出して作成しました。形式はSSH-2 RSAの1024としました。この鍵がそもそも駄目ということでしょうか?
Bakudankun

2016/10/16 14:09 編集

PuTTY Key Generatorから作成できるSSH秘密鍵はPuTTY用のppk形式の鍵であり、OpenSSH(ターミナルのsshコマンド)では使えないためです。PuTTY Key Generatorにppk形式の鍵をOpenSSH形式にコンバートする機能があったと思うので、それを使ってOpenSSH形式の鍵を作成(本来はこれが`$HOME/.ssh/id_rsa`です)すればsshコマンドでも使えるようになると思います。
choitarou

2016/10/16 14:42

ご丁寧にありがとうございます。明日の朝一で確認してみます。結果もご報告させて頂きます。
choitarou

2016/10/17 07:14

返信が遅くなって申し訳ありません。ご教授頂いたとおり、openssh keyにして無事接続することができました!本当に助かりました、ありがとうございました。
choitarou

2016/10/17 07:19

すみません、ベストアンサーをつけようと思ったのですが、ここに書いているとつけれないみたいですね。><自己解決でcloseにしておきます。
guest

回答1

0

自己解決

鍵をputty形式から、openssh形式にしたら解決しました。

投稿2016/10/17 07:19

choitarou

総合スコア112

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.29%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問