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

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

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

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

SSH

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

AWS(Amazon Web Services)

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

Q&A

解決済

1回答

2808閲覧

AWS Cloud9からEC2インスタンスにSSH接続できない

apple_japan

総合スコア57

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

SSH

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

AWS(Amazon Web Services)

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

0グッド

0クリップ

投稿2018/07/13 04:59

編集2018/07/13 05:09

↓やったこと、設定など↓

【AWS Cloud9】

リージョン:シンガポール
・Connect and run in remote server (SSH)を選択
・User→centos
・Host→IPv4 パブリック IPを入力
・Port→22
・public SSH key→~/.ssh/authorized_keysに追記済み
・Environment path→/home/kusanagi

エラーメッセージ
AWS Cloud9 couldn't connect to SSH server centos@パブリックIP

【EC2】

リージョン:シンガポール
セキュリティグループ→タイプ:SSH、ポート範囲:22、ソース:0.0.0.0/0
~/.ssh/authorized_keysのパーミッション→600
~/.sshのパーミッション→700
/home/kusanagiのパーミッション755
/etc/hosts.allow→sshd: ALLのみ
/etc/hosts.deny→vsftpd : allのみ
sshdの再起動→systemctl restart sshd.service

以下/etc/ssh/sshd_configの内容です。

bash

1# This is the sshd server system-wide configuration file. See 2# sshd_config(5) for more information. 3 4# This sshd was compiled with PATH=/usr/local/bin:/usr/bin 5 6# The strategy used for options in the default sshd_config shipped with 7# OpenSSH is to specify options with their default value where 8# possible, but leave them commented. Uncommented options override the 9# default value. 10 11# If you want to change the port on a SELinux system, you have to tell 12# SELinux about this change. 13# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER 14# 15#Port 22 16#AddressFamily any 17#ListenAddress 0.0.0.0 18#ListenAddress :: 19 20# The default requires explicit activation of protocol 1 21#Protocol 2 22 23# HostKey for protocol version 1 24#HostKey /etc/ssh/ssh_host_key 25# HostKeys for protocol version 2 26HostKey /etc/ssh/ssh_host_rsa_key 27#HostKey /etc/ssh/ssh_host_dsa_key 28HostKey /etc/ssh/ssh_host_ecdsa_key 29HostKey /etc/ssh/ssh_host_ed25519_key 30 31# Lifetime and size of ephemeral version 1 server key 32#KeyRegenerationInterval 1h 33#ServerKeyBits 1024 34 35# Ciphers and keying 36#RekeyLimit default none 37 38# Logging 39# obsoletes QuietMode and FascistLogging 40#SyslogFacility AUTH 41SyslogFacility AUTHPRIV 42#LogLevel INFO 43 44# Authentication: 45 46#LoginGraceTime 2m 47PermitRootLogin no 48#StrictModes yes 49#MaxAuthTries 6 50#MaxSessions 10 51 52#RSAAuthentication yes 53#PubkeyAuthentication yes 54 55# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 56# but this is overridden so installations will only check .ssh/authorized_keys 57AuthorizedKeysFile .ssh/authorized_keys 58 59#AuthorizedPrincipalsFile none 60 61#AuthorizedKeysCommand none 62#AuthorizedKeysCommandUser nobody 63 64# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts 65#RhostsRSAAuthentication no 66# similar for protocol version 2 67#HostbasedAuthentication no 68# Change to yes if you don't trust ~/.ssh/known_hosts for 69# RhostsRSAAuthentication and HostbasedAuthentication 70#IgnoreUserKnownHosts no 71# Don't read the user's ~/.rhosts and ~/.shosts files 72#IgnoreRhosts yes 73 74# To disable tunneled clear text passwords, change to no here! 75#PasswordAuthentication yes 76#PermitEmptyPasswords no 77PasswordAuthentication no 78 79# Change to no to disable s/key passwords 80#ChallengeResponseAuthentication yes 81ChallengeResponseAuthentication no 82 83# Kerberos options 84#KerberosAuthentication no 85#KerberosOrLocalPasswd yes 86#KerberosTicketCleanup yes 87#KerberosGetAFSToken no 88#KerberosUseKuserok yes 89 90# GSSAPI options 91GSSAPIAuthentication yes 92GSSAPICleanupCredentials no 93#GSSAPIStrictAcceptorCheck yes 94#GSSAPIKeyExchange no 95#GSSAPIEnablek5users no 96 97# Set this to 'yes' to enable PAM authentication, account processing, 98# and session processing. If this is enabled, PAM authentication will 99# be allowed through the ChallengeResponseAuthentication and 100# PasswordAuthentication. Depending on your PAM configuration, 101# PAM authentication via ChallengeResponseAuthentication may bypass 102# the setting of "PermitRootLogin without-password". 103# If you just want the PAM account and session checks to run without 104# PAM authentication, then enable this but set PasswordAuthentication 105# and ChallengeResponseAuthentication to 'no'. 106# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several 107# problems. 108UsePAM yes 109 110#AllowAgentForwarding yes 111#AllowTcpForwarding yes 112#GatewayPorts no 113X11Forwarding yes 114#X11DisplayOffset 10 115#X11UseLocalhost yes 116#PermitTTY yes 117#PrintMotd yes 118#PrintLastLog yes 119#TCPKeepAlive yes 120#UseLogin no 121UsePrivilegeSeparation sandbox # Default for new installations. 122#PermitUserEnvironment no 123#Compression delayed 124ClientAliveInterval 120 125ClientAliveCountMax 5 126#ShowPatchLevel no 127#UseDNS yes 128#PidFile /var/run/sshd.pid 129#MaxStartups 10:30:100 130#PermitTunnel no 131#ChrootDirectory none 132#VersionAddendum none 133 134# no default banner path 135#Banner none 136 137# Accept locale-related environment variables 138AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES 139AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT 140AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE 141AcceptEnv XMODIFIERS 142 143# override default of no subsystems 144Subsystem sftp /usr/libexec/openssh/sftp-server 145 146# Example of overriding settings on a per-user basis 147#Match User anoncvs 148# X11Forwarding no 149# AllowTcpForwarding no 150# PermitTTY no 151# ForceCommand cvs server

下記コマンドでsshのログを確認。
cat /var/log/secure

Jul 13 12:32:29 kusanagi80 sshd[1994]: Connection closed by 13.250.186.128 port 8000 [preauth] Jul 13 12:32:29 kusanagi80 sshd[1996]: Connection closed by 13.250.186.128 port 50727 [preauth] Jul 13 12:32:29 kusanagi80 sshd[1998]: Connection closed by 13.250.186.128 port 46521 [preauth]

13.250.186.128はCloud9のIPかと思われます。

他に何か接続できない原因など考えられますでしょうか?
よろしくお願いいたします。

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

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

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

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

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

guest

回答1

0

自己解決

公開鍵を.ssh/authorized_keysではなく/home/ユーザー名/.ssh/authorized_keysに追記することで接続することができました。

投稿2018/07/14 10:21

apple_japan

総合スコア57

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問