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

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

新規登録して質問してみよう
ただいま回答率
85.48%
Sequel Pro

Sequel Proは、Mac OS X向けMySQLフロントエンドです。GUIからのMySQLの操作・管理が可能になります。強力なクエリ編集、多彩なエンコーディングオプションのサポートなど多くの機能を備えています。

Ruby on Rails

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

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

1回答

884閲覧

【Rails】本番環境でSequelProを使いたい

yastinbieber

総合スコア49

Sequel Pro

Sequel Proは、Mac OS X向けMySQLフロントエンドです。GUIからのMySQLの操作・管理が可能になります。強力なクエリ編集、多彩なエンコーディングオプションのサポートなど多くの機能を備えています。

Ruby on Rails

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

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2021/05/15 11:30

編集2021/05/16 02:50

前提

RailsにてWEBアプリケーションを作っております。
EC2を利用し、デプロイまで成功させております。

実現したいこと

本番環境において、SequelProを使用し、DB管理をしたいです。

以下の通り本番環境においてMysqlのDBは作成されております。

ec2-user:~/environment $ cd ~/.ssh ec2-user:~/.ssh $ ssh -i torekabodymake_keypair.pem ec2-user@54.249.173.184 Last login: Thu May 13 00:11:18 2021 from 54.249.212.198 __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ [ec2-user@ip-172-31-36-245 ~]$ cd /var/www/git_toreka [ec2-user@ip-172-31-36-245 git_toreka]$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 85 Server version: 8.0.22 MySQL Community Server - GPL Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | git_toreka | | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.06 sec)

試したこと

こちらのサイトを参考に以下のようにSequelPro上で操作してみました。

イメージ説明
イメージ説明

すると2枚めのように『SSH接続が失敗しました』と表記が出てしまいます。

なお『詳細を表示』ボタンから確認できる内容は下記となります。

Used command: /usr/bin/ssh -v -N -S none -o ControlMaster=no -o ExitOnForwardFailure=yes -o ConnectTimeout=10 -o NumberOfPasswordPrompts=3 -i /Users/yastinbieber/Downloads/torekabodymake_keypair.pem -o TCPKeepAlive=no -o ServerAliveInterval=60 -o ServerAliveCountMax=1 -p 22 ec2-user@54.249.173.184 -L 55060:127.0.0.1:3306 OpenSSH_8.1p1, LibreSSL 2.7.3 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 47: Applying options for * debug1: Control socket " none" does not exist debug1: Connecting to 54.249.173.184 [54.249.173.184] port 22. debug1: fd 3 clearing O_NONBLOCK debug1: Connection established. debug1: identity file /Users/yastinbieber/Downloads/torekabodymake_keypair.pem type -1 debug1: identity file /Users/yastinbieber/Downloads/torekabodymake_keypair.pem-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.1 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002 debug1: Authenticating to 54.249.173.184:22 as 'ec2-user' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 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: ecdsa-sha2-nistp256 SHA256:273QxtYusMEyPX3qA2kiWHOeU2qyePbJKjRbAGdZNFA debug1: Host '54.249.173.184' is known and matches the ECDSA host key. debug1: Found key in /Users/yastinbieber/.ssh/known_hosts:1 debug1: rekey out after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey in after 134217728 blocks debug1: Will attempt key: /Users/yastinbieber/Downloads/torekabodymake_keypair.pem explicit debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic debug1: Next authentication method: publickey debug1: Trying private key: /Users/yastinbieber/Downloads/torekabodymake_keypair.pem @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/Users/yastinbieber/Downloads/torekabodymake_keypair.pem' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "/Users/yastinbieber/Downloads/torekabodymake_keypair.pem": bad permissions debug1: No more authentication methods to try. ec2-user@54.249.173.184: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

恐れ入りますが要因がわかる方ご教示いただけますと幸いです。

補足情報(FW/ツールのバージョンなど)

Rails 5.2.5
ruby 2.5.1
EC2
AWS

追記

$ cd ~ $ mkdir ~/.ssh # .sshというディレクトリを作成 # File existsとエラーが表示されたとしても、.sshディレクトリは存在しているということなので、そのまま進みましょう。 $ mv Downloads/ダウンロードした鍵の名前.pem .ssh/ # mvコマンドで、ダウンロードしたpemファイルを、ダウンロードディレクトリから、.sshディレクトリに移動します。 $ cd .ssh/ $ ls # pemファイルが存在するか確認しましょう $ chmod 600 ダウンロードした鍵の名前.pem $ ssh -i ダウンロードした鍵の名前.pem ec2-user@作成したEC2インスタンスと紐付けたElastic IP #(例えばElastic IPが123.456.789であれば、shh -i ダウンロードした鍵の名前.pem ec2-user@123.456.789 というコマンドになります) #(ダウンロードした鍵を用いて、ec2-userとしてログイン)

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

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

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

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

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

guest

回答1

0

ベストアンサー

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/yastinbieber/Downloads/torekabodymake_keypair.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/Users/yastinbieber/Downloads/torekabodymake_keypair.pem": bad permissions

ここの部分が答えです。
せっかくメッセージが表示されているので内容をきちんと確認しましょう。

鍵ファイルの権限が過剰なので、600か400(つまり、自分以外のユーザが読み書きできない権限)にする必要があります。

shell

1chmod 600 <鍵ファイルのパス>

で、権限を変更できます。400にしたい場合は600のところを400にしてください。

投稿2021/05/15 14:03

yu_1985

総合スコア7447

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

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

yastinbieber

2021/05/16 02:49

回答ありがとうございます。 エラー内容をみて疑問に思ったのですが、 以前にEC2インスタンスへログインするためにmvコマンドで作成したpemファイルをダウンロードディレクトリからsshディレクトリへ移動したことがあります。 そのときに打ったコマンドを追記しておきます。 ターミナルで確認するとしっかりと格納されております。 ec2-user:~ $ cd .ssh/ ec2-user:~/.ssh $ ls authorized_keys id_rsa id_rsa.pub known_hosts torekabodymake_keypair.pem なおこの操作の際に $ chmod 600 ダウンロードした鍵の名前.pem の操作もしております。 もしかするとSequelPro上でのpemファイルの選択が間違ってるのかなとも思ったのですが。。 現在の操作では、pemファイルの格納先が '/Users/yastinbieber/Downloads/torekabodymake_keypair.pem' となっておりますが、cloud9で開発していることと移動したことを考えると、 '/.ssh/torekabodymake_keypair.pem' となるのが正しいのかなとも思えまして。。
yu_1985

2021/05/16 05:31

ローカルに配置する秘密鍵はどこに置いてあっても関係ありません。通例上ローカルでも.sshに置くことが多いだけです。 本当に権限変わっていますか? ls -l などでちゃんと確認してください。
yastinbieber

2021/05/16 08:58

下記確認内容となります。 この権限だといけないのでしょうか?? ec2-user:~/.ssh $ ls -l total 20 -rw------- 1 ec2-user ec2-user 991 Jul 12 2020 authorized_keys -rw------- 1 ec2-user ec2-user 1679 Nov 5 2020 id_rsa -rw-r--r-- 1 ec2-user ec2-user 407 Nov 5 2020 id_rsa.pub -rw-r--r-- 1 ec2-user ec2-user 1990 Jan 10 05:54 known_hosts -rw------- 1 ec2-user ec2-user 1678 Jan 9 06:44 torekabodymake_keypair.pem ec2-user:~/.ssh $
yu_1985

2021/05/16 11:12

それはサーバ上の.sshなので、そこにEC2にSSHするための秘密鍵を置いても関係ありません。 ローカルの鍵の権限が足りないという話なのでそちらと確認してください。
yastinbieber

2021/05/17 08:42

ローカルの方をいじるんですね。 確認したところ権限が違ったようで修正いたしました。 Mysql8によるエラーが次に出てきてしまいましたが、 今回質問させていただいた内容はクリアできたので解決済みとさせていただきます。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問