SSH ポート転送が機能しません。エラーが発生しました

SSH ポート転送が機能しません。エラーが発生しました

私は(sshコマンドを実行して)リモートサーバーによって制御される必要があるローカルラップトップMacOSをlocalmac持っています。macuserremotelinuxlinuxuser

私はlocalmac成功することができますssh linuxuser@remotelinux

私の場合は、localmac次のようにトンネルを公開しました。

ssh -fnN -R 4444:localhost:22  linuxuser@remotelinux

これで、remotelinux次のコマンドを使用してキーをコピーしようとしてエラーが発生します。

$ ssh-copy-id -p 4444 macuser@localhost
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/linuxuser/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: ERROR: ssh_exchange_identification: Connection closed by remote host

上記の方法が失敗したことがわかりましたが、次のようにRemoteLinuxでホスト名コマンドをトリガーしてみました。

[linuxuser@remotelinux ~]$ ssh -p 3334 macuser@localhost 'hostname' -vvvv
ssh_exchange_identification: Connection closed by remote host
[linuxuser@remotelinux ~]$ ssh -p 3334 macuser@localhost -vvvv
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 3334
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [::1] port 3334.
debug1: Connection established.
debug1: identity file /home/linuxuser/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/linuxuser/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/linuxuser/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/linuxuser/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/linuxuser/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/linuxuser/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/linuxuser/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/linuxuser/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
ssh_exchange_identification: Connection closed by remote host

localmac私が実行したすべてのSSHコマンドに対して次のメッセージが印刷されることがわかりました。remotelinux

SSH tunneling: connect_to localhost port 22: failed

動作させる方法を提案してもらえますか?

ベストアンサー1

MacOSノートブックでは、リモートログインがデフォルトで無効になっているため、SSHは失敗します。環境設定に移動して有効にします。

おすすめ記事