22以外のポートを使用してRedhat AWSインスタンスに接続しようとしています。
このコマンドは機能しますが、次のコマンドは機能しません。ssh -i my.pem -p 22 [email protected]
ssh -i my.pem -p 8157 -vvv [email protected]
2番目のコマンド出力:
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 *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to X.X.X.X port 8157.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file my.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file my.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
ところで、ただ切れました。接続しようとしているサーバーで実行すると表示されますnc -l 8157
。
SSH-2.0-OpenSSH_7.6
部品を取り出すと、-vvv
「接続拒否」エラーが発生します。
パソコンにログインして実行するとssh -p 8157 -vvv ec2-user@localhost
次の結果が表示されます。
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 *
debug2: resolving "localhost" port 8157
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 8157.
debug1: connect to address 127.0.0.1 port 8157: Connection refused
ssh: connect to host localhost port 8157: Connection refused
何が起こったのか知っていますか?
ベストアンサー1
このコマンドの仕組み:
ssh -i my.pem -p 22 [email protected]
ただし、このコマンドは次のことを行いません。
ssh -i my.pem -p 8157 -vvv [email protected]
ファイアウォールの反対側にポートが開いている可能性があります...
ポート 22 が有効なため、サーバーはそのポートでリッスンします。
目的のポートでリッスンするようにサーバーを再構成します。
ファイルでこれを行うことができます。
/etc/ssh/sshd_config
次の設定を使用します。
Port 8157
後でSSHデーモンを再起動することを忘れないでください。