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

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

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Git

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

SSH

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

Q&A

解決済

2回答

2829閲覧

Bitbucketにpushできない。

Ryota000666

総合スコア7

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Git

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

SSH

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

0グッド

1クリップ

投稿2020/02/18 08:23

編集2020/02/18 11:50

前提・実現したいこと

bitbucketにpushできるようにしたい。
bitbucketにpushできないためリポジトリが作成されません。

SSHキーが原因かと思い、SSHキーを変更したりしましたが、解決されませんでした。

Rails チュートリアル勉強中です。

発生している問題・エラーメッセージ

ec2-user:~/environment/sample_app (master) $ git push -u origin --all The authenticity of host 'bitbucket.org (18.205.93.0)' can't be established. RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A. RSA key fingerprint is MD5:97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40. Are you sure you want to continue connecting (yes/no)? Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

該当のソースコード

ソースコード

試したこと

SSHキーの変更

追記

いろいろ試みていると以下のようなメッセージが出てきました。

ec2-user:~/environment/toy_app (master) $ git push -u origin --all Warning: Permanently added the RSA host key for IP address '18.205.93.0' to the list of known hosts. To bitbucket.org:Ryota000666/toy_app.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@bitbucket.org:Ryota000666/toy_app.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

ここにより詳細な情報を記載してください。

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

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

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

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

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

guest

回答2

0

ベストアンサー

RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A. RSA key fingerprint is MD5:97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40. Are you sure you want to continue connecting (yes/no)?

ここまで表示された時に一度止まるはずですが、ここでそのまま Enter キー等を押していませんか?
上記は bitbucket.org が持っているホスト鍵が正しいかどうかを確認しています。

Bitbucketのサポート情報を見ると上記ホスト鍵はbitbucket.org の正しいホスト鍵なので、再度git push を実行し、fingerprintが上記と変わっていない事を確認した上で yes を入力してください。


Warning: Permanently added 'bitbucket.org,18.205.93.2' (RSA) to the list of known hosts. Authentication failed.

ホスト鍵の確認までは通るようになったので一歩進みましたね。
エラーメッセージを見ると今度はsshの認証が失敗しています。

ssh -v git@bitbucket.org を実行した時の出力はどうなりますか?
追記された内容を読んでいませんでした。

To bitbucket.org:Ryota000666/toy_app.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@bitbucket.org:Ryota000666/toy_app.git'

このエラーが出たという事はsshでの接続が成功して、gitリポジトリにアクセスする所までは出来ています。以降はsshではなくgitでの問題という事になります。

エラーの原因はローカル側にない変更がリモート側にある事です。
fetch first と言われているようにまず git fetch origin を実行してください。
その後 git log origin/mastergit diff origin/master を実行してリモートの変更内容を確認します。

変更内容が必要なものだった場合、git merge origin/master で変更内容をマージ後、再度 git push -u origin --all を実行します。

変更内容が必要ないものだったならば、git push --force -u origin --all を実行して強制的にpushするのが楽でしょう。

注意

この回答は「Railsチュートリアル勉強中」という事から、Bitbucketのリポジトリは個人で使っていて自分以外はアクセスに来ない事を想定しています。
他の人も使っているリポジトリでは git push --force の利用は避ける事をお勧めします。

投稿2020/02/18 11:27

編集2020/02/19 11:42
doda

総合スコア947

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

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

Ryota000666

2020/02/18 11:38

ec2-user:~/environment/toy_app (master) $ git push -u origin --all The authenticity of host 'bitbucket.org (18.205.93.2)' can't be established. RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A. RSA key fingerprint is MD5:97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'bitbucket.org,18.205.93.2' (RSA) to the list of known hosts. Authentication failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. このような結果が返ってきました。
Ryota000666

2020/02/19 00:31 編集

ご返信ありがとうございます。 ec2-user:~/environment/toy_app (master) $ ssh -v git@bitbucket.org OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 58: Applying options for * debug1: Connecting to bitbucket.org [18.205.93.2] port 22. debug1: Connection established. debug1: identity file /home/ec2-user/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/ec2-user/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/ec2-user/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/ec2-user/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/ec2-user/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/ec2-user/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/ec2-user/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/ec2-user/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.4 debug1: Remote protocol version 2.0, remote software version conker_4148b469a9 app-153 debug1: no match: conker_4148b469a9 app-153 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: kex: curve25519-sha256@libssh.org need=64 dh_need=64 debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64 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 /home/ec2-user/.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 RSA public key: /home/ec2-user/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 279 debug1: Authentication succeeded (publickey). Authenticated to bitbucket.org ([18.205.93.2]:22). debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: pledge: network debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 PTY allocation request failed on channel 0 logged in as ryota000666 You can use git or hg to connect to Bitbucket. Shell access is disabled debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 Connection to bitbucket.org closed. Transferred: sent 3112, received 1852 bytes, in 0.0 seconds Bytes per second: sent 114226.6, received 67978.0 debug1: Exit status 0 試してみました。
doda

2020/02/19 11:44

回答にも追記しましたが、ここまで行ってるのならばもう ssh 接続は問題無いです。 あとは git での問題となります。
guest

0

SSHキーが原因かと思い、SSHキーを変更したりしました

ssh-keygenコマンドで作成した公開鍵はBitbucketの管理画面から登録していますか?
BitbucketにSSH認証鍵を設定する - Qiita

投稿2020/02/18 08:45

miyabi-sun

総合スコア21158

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

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

Ryota000666

2020/02/18 11:39

はい、管理画面から登録しました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問