質問をすることでしか得られない、回答やアドバイスがある。

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

新規登録して質問してみよう
ただいま回答率
85.49%
Git

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

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

BitBucket

BitBucketは無料のリポジトリ管理ホスティングサービスです。 MercurialとGitのVCSに対応しています。プライベートリポジトリを、制限なく作成することが可能です。

Q&A

解決済

1回答

5864閲覧

bitbucketでssh接続に何度か失敗してしまう

tinmanCtr

総合スコア9

Git

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

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

BitBucket

BitBucketは無料のリポジトリ管理ホスティングサービスです。 MercurialとGitのVCSに対応しています。プライベートリポジトリを、制限なく作成することが可能です。

0グッド

0クリップ

投稿2018/08/27 08:35

編集2018/08/27 09:17

Bitbucketにpushしようと、$ git push origin masterを実行すると、

fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

とエラーが出ます。(Permission deniedとは出ません)

ssh鍵の設定はしています。(~/.ssh配下にid_rsa, id_rsa.pub, known_hostsがあります)
もちろんoriginもBitbucketのリモートリポジトリとして設定しています。

タイトルに「何度か」と書いたのは、私が$ ssh -T git@bitbucket.orgで接続を試みると、何度かはメッセージが返ってこず、3,4回したところでやっと、

logged in as <ユーザー名>. You can use git or hg to connect to Bitbucket. Shell access is disabled.

というメッセージが来るわけです。ここで$ git pushすると成功します。

つまり、ssh接続の問題だと思うのですが、ネットで似たような事例を見つけられないので、なぜこのようになるか&解決方法が分かる方ご教授お願いします。

追記:失敗するときのlog(投げやりで申し訳ありません)

OpenSSH_7.6p1, LibreSSL 2.6.2 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48: Applying options for * debug1: Connecting to bitbucket.org port 22. debug1: Connection established. debug1: identity file /Users/<ユーザー名>/.ssh/id_rsa type 0 debug1: key_load_public: No such file or directory debug1: identity file /Users/<ユーザー名>/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/<ユーザー名>/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/<ユーザー名>/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/<ユーザー名>/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/<ユーザー名>/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/<ユーザー名>/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/<ユーザー名>/.ssh/id_ed25519-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.6 debug1: Remote protocol version 2.0, remote software version conker_1.1.13-7af6557 app-131 debug1: no match: conker_1.1.13-7af6557 app-131 debug1: Authenticating to bitbucket.org:22 as 'git' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256@libssh.org debug1: kex: host key algorithm: ssh-rsa debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A debug1: Host 'bitbucket.org' is known and matches the RSA host key. debug1: Found key in /Users/<ユーザー名>/.ssh/known_hosts:1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering public key: RSA SHA256:<公開鍵> /Users/<ユーザー名>/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 279 Enter passphrase for key '/Users/<ユーザー名>/.ssh/id_rsa': Connection closed by 2406:da00:ff00::22cd:e0db port 22

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

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

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

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

デバッグログからすると 失敗しているときは、IPv6 で接続されているようですが、ssh の設定で、IPv4 を指定して接続すると接続できたりしないでしょうか?

IPv4 のみで接続する場合は、ssh の設定ファイル ~/.ssh/config

Host bitbucket.org HostName bitbucket.org AddressFamily inet

のような設定をします。

なお、AddressFamily を inet6 とすると IPv6 のみを使用します。

投稿2018/08/27 22:55

CHERRY

総合スコア25171

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

tinmanCtr

2018/08/28 04:12

解決しました!ありがとうございます! とはいえ何のことか分からないので、もっとsshについて勉強します。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.49%

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

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

質問する

関連した質問