リバースSSHは機能しますが、パスワードがないわけではありません。パスワードのヒントを受け取る

リバースSSHは機能しますが、パスワードがないわけではありません。パスワードのヒントを受け取る

2つのシステムがあります

  1. system-LaptopプライベートMacOSノートブックは所有ユーザーとして知られていますlaptopuser。 「NAT」はありません。

  2. サーバーLinuxは、誰でもアクセスできるsystem-Server固定IPを持つユーザーです。serveruser

system-Server「NAT」なしで動的IPを取得sshするには、コマンドを送信する必要があります。system-Laptopreverse SSH tunnelsystem-Laptop

私が設定した方法は次のssh-keysとおりです。reverse SSH

ステップ1:laptopuseronのキーペアを作成system-Laptopし、公開キーid_rsa.pubをself~/.ssh/authorized_keysとonにsystem-Serverコピーします。<serveruserhomedir>/.ssh/authorized_keys

ステップ2:

serveruseronの鍵ペアを作成し、system-Server公開鍵id_rsa.pubをselfにコピーして~/.ssh/authorized_keysからonにコピーしますsystem-Laptop<laptopuserhomedir>/.ssh/authorized_keys

注:このコマンドを正常にテストできますsystem-Laptop- >ssh serveruser@system-Server

ステップ3:

system-LaptopSSHトンネルを保存するには、次のコマンドを実行します。

ssh -N -R 3322:localhost:22 serveruser@system-Server

ステップ4:

次のコマンドを実行して、Linuxサーバーからマイノートブックに接続します。

ssh -p 3322 laptopuser@localhost

問題は、上記のコマンドがパスワードを求めるメッセージを表示することです。laptopuserパスワードを入力すると機能します。

SSHキーを使用して上記の操作をパスワードなしで実行するにはどうすればよいですか?私が逃したものは何ですか? [reverse-ssh]は今回が初めてだとよくわかりません。

以下は、ステップ4 sshコマンドのデバッグ出力です。

ssh -p 3322 laptopuser@localhost
.......
.......
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug2: key: /home/serveruser/.ssh/id_rsa (0x56539b783370)
debug2: key: /home/serveruser/.ssh/id_dsa ((nil))
debug2: key: /home/serveruser/.ssh/id_ecdsa ((nil))
debug2: key: /home/serveruser/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/serveruser/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/serveruser/.ssh/id_dsa
debug3: no such identity: /home/serveruser/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/serveruser/.ssh/id_ecdsa
debug3: no such identity: /home/serveruser/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/serveruser/.ssh/id_ed25519
debug3: no such identity: /home/serveruser/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 60
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password:


[serveruser@system-Server ~]$ ls -ltr /home/serveruser/.ssh/id_rsa
-rw------- 1 serveruser serveruser 3243 Jan 15 21:01 /home/serveruser/.ssh/id_rsa

ベストアンサー1

まず、SSHキーをコピーする最も簡単な方法は、次を使用することです。SSHコピーID注文する。両方のユーザーに対してこれを行います。

次に、リバーストンネルを作成するには、次のコマンドを使用します(ノートブックで実行)。

ssh -fnN -R 3322:localhost:22 serveruser@system-server

最後にトンネルサービスに接続します。以前に ssh-copy-id が完了した場合、パスワードは要求されません。システムサーバーで次のコマンドを実行して、リモートLinuxサーバーからノートブックへの新しいSSHセッションを開始します。

ssh -p 3322 laptopuser@localhost

おすすめ記事