web-dev-qa-db-ja.com

RDPが応答するポートを指定するにはどうすればよいですか?

RDP(リモートデスクトップ)がRHP(ランダムハイポート)ではなく特定のポートに応答するように強制する方法を理解する必要があります。 RDPが「リッスン」するポートを変更する方法を尋ねているのではなく、その逆です。

2つのシステム間に実験的な順方向/逆方向SSHトンネルを設定しようとしています。フォワードトンネルでIPを隠すためのピボットポイントとして3番目のシステムを使用しています。しかし、フォワードSSHトンネルを介してリモーティングしているシステムが、別のリバースSSHトンネルを介してRHPではなく「指定された」ポートに応答を送信するようにしたい。基本的な考え方は、リッスンまたは受信するポートを制御できるようにしたいということです。また、ランダムなものは必要ありません。そうは言っても、ここに私のセットアップのスナップショットがあります。

編集:画像内のすべてのIPアドレスが変更されたため、後で質問に編集したログを読んだときに混乱します。新しいIPアドレスは次のとおりです。

  • KGRAVES-10.0.10.11
  • DEVILSMILK-10.0.10.121
  • DUCLAW-10.0.10.12

enter image description here

最後のステップでわかるように、私のRDPセッションは、必要に応じてリバースSSHトンネルを介して返送されています。したがって、RDPセッション用に2つのパイプがあります。しかし、それはRHPで返送されており、特定のポート、たとえば:44444に送信するように指示する方法がわかりません。

誰かがこれを行う方法を知っていますか?

私はこれを特定の方法で行う必要があります。これらは私が使用するポートです持っている1337ではなくポート3389Duclawをリ​​ッスンするようにRDPを既に設定しています。 これが決して最も簡単な方法ではないことを私は知っています。

リモートデスクトップ接続をdevilsmilkから来ているかのように「表示」する必要があります。しかし、duclawを経由せずに、devilsmilkが応答をkgraves-pcに直接返送するようにしたい。したがって、kgraves-pcに対して、RDPセッションはlocalhostに送信され、sshトンネルを介してdevilsmilkを介してduclawに転送されますが、RDPから直接受信されているDuclawパケットは、それに応答して_.

私のコマンドは次のとおりです。kgraves-pcの別のCYGWIN端末から行ったssh接続を除いて、すべてはkgraves-pcのまったく同じmstscCYGWINコンソールから実行されます。

CNO\kgraves@KGRAVES ~
$ ssh -vg -L 3333:localhost:6666 misfitred@devilsmilk
OpenSSH_6.1p1, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to devilsmilk [10.0.10.121] port 22.
debug1: Connection established.
debug1: identity file /home/kgraves/.ssh/id_rsa type 1
debug1: identity file /home/kgraves/.ssh/id_rsa-cert type -1
debug1: identity file /home/kgraves/.ssh/id_dsa type -1
debug1: identity file /home/kgraves/.ssh/id_dsa-cert type -1
debug1: identity file /home/kgraves/.ssh/id_ecdsa type -1
debug1: identity file /home/kgraves/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.1
key_read: uudecode devilsmilk ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwVZRlnAgPRPxTx           cbTPALg5XPpOnAMhJabQ3Dv/7a95eqe5l7XnKRciYQZ41B61DRgXCzC/M9ObknMR79zG0mkSl+jQTGJ7           klol7nw0+U1dNFknv4fOn+YGAsqECclWEow3OK5xRcla5eBekRGWjrZ7Wbs4F3FeKGQNqU/OuGvdSaQb           3nqgLPGTZfRhNtykQvpNzXw5cjO7XvM0BBv9di4JblLx9Fk3iq2KwdgWmK9uFDPYjU1gkHR8hk+bns1t           16KFcyDKnzhR1CblU6JT/wlBtnFa11no1UJBEHC2UQy8trwkMU6NqUt0X+D/XqW5F6+uWNc/dY97CCky           9HdfWNGQ==
 failed
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server Host key: RSA b5:d6:eb:64:50:2f:40:04:32:10:bb:4f:a8:d3:f5:37
key_read: uudecode devilsmilk ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwVZRlnAgPRPxTx           cbTPALg5XPpOnAMhJabQ3Dv/7a95eqe5l7XnKRciYQZ41B61DRgXCzC/M9ObknMR79zG0mkSl+jQTGJ7           klol7nw0+U1dNFknv4fOn+YGAsqECclWEow3OK5xRcla5eBekRGWjrZ7Wbs4F3FeKGQNqU/OuGvdSaQb           3nqgLPGTZfRhNtykQvpNzXw5cjO7XvM0BBv9di4JblLx9Fk3iq2KwdgWmK9uFDPYjU1gkHR8hk+bns1t           16KFcyDKnzhR1CblU6JT/wlBtnFa11no1UJBEHC2UQy8trwkMU6NqUt0X+D/XqW5F6+uWNc/dY97CCky           9HdfWNGQ==
 failed
The authenticity of Host 'devilsmilk (10.0.10.121)' can't be established.
RSA key fingerprint is b5:d6:eb:64:50:2f:40:04:32:10:bb:4f:a8:d3:f5:37.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'devilsmilk' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interacti           ve
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/kgraves/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interacti           ve
debug1: Trying private key: /home/kgraves/.ssh/id_dsa
debug1: Trying private key: /home/kgraves/.ssh/id_ecdsa
debug1: Next authentication method: keyboard-interactive
Password:
debug1: Authentication succeeded (keyboard-interactive).
Authenticated to devilsmilk ([10.0.10.121]:22).
debug1: Local connections to *:3333 forwarded to remote address localhost:6666
debug1: Local forwarding listening on :: port 3333.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 0.0.0.0 port 3333.
debug1: channel 1: new [port listener]
debug1: channel 2: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
Last login: Wed Jan 30 16:13:02 2013 from kgraves.cno.local
[misfitred@devilsmilk ~]$ ssh -vg -L 6666:localhost:1337 kgraves@duclaw
OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to duclaw [10.0.10.120] port 22.
debug1: Connection established.
debug1: identity file /home/misfitred/.ssh/id_rsa type 1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.1
debug1: match: OpenSSH_6.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'duclaw' is known and matches the RSA Host key.
debug1: Found key in /home/misfitred/.ssh/known_hosts:3
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interacti           ve
debug1: Next authentication method: publickey
debug1: Offering public key: /home/misfitred/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interacti           ve
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interacti           ve
debug1: Next authentication method: password
kgraves@duclaw's password:
debug1: Authentication succeeded (password).
debug1: Local connections to *:6666 forwarded to remote address localhost:1337
debug1: Local forwarding listening on 0.0.0.0 port 6666.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on :: port 6666.
debug1: channel 1: new [port listener]
debug1: channel 2: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Wed Jan 30 15:55:29 2013 from devilsmilk.cno.local
"tty" option detected in CYGWIN environment variable.
CYGWIN=tty is no longer supported.  Please remove it from your
CYGWIN environment variable and use a terminal emulator like mintty,
xterm, or rxvt.

kgraves@DUCLAW ~
$ ssh -vg -R 3333:devilsmilk:6666 kgraves@kgraves
OpenSSH_6.1p1, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to kgraves [10.0.10.113] port 22.
debug1: Connection established.
debug1: identity file /home/kgraves/.ssh/id_rsa type 1
debug1: identity file /home/kgraves/.ssh/id_rsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.1
debug1: match: OpenSSH_6.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server Host key: ECDSA de:1c:37:d7:84:0b:f8:f9:5e:da:11:49:57:4f:b8:f1
debug1: Host 'kgraves' is known and matches the ECDSA Host key.
debug1: Found key in /home/kgraves/.ssh/known_hosts:3
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interacti           ve
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/kgraves/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interacti           ve
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interacti           ve
debug1: Next authentication method: password
kgraves@kgraves's password:
debug1: Authentication succeeded (password).
Authenticated to kgraves ([10.0.10.113]:22).
debug1: Remote connections from LOCALHOST:3333 forwarded to local address devils           milk:6666
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: remote forward failure for: listen 3333, connect devilsmilk:6666
Warning: remote port forwarding failed for listen port 3333
debug1: All remote forwarding requests processed
Last login: Wed Jan 30 16:21:12 2013 from duclaw.cno.local
"tty" option detected in CYGWIN environment variable.
CYGWIN=tty is no longer supported.  Please remove it from your
CYGWIN environment variable and use a terminal emulator like mintty,
xterm, or rxvt.
_____________________________________________________________________________
##From separate CYGWIN Terminal##
CNO\kgraves@KGRAVES ~
$ mstsc /v:localhost:3333 /f

CNO\kgraves@KGRAVES ~
$
_____________________________________________________________________________

kgraves@KGRAVES ~
$ debug1: Connection to port 3333 forwarding to localhost port 6666 requested.
debug1: channel 4: new [direct-tcpip]
debug1: Connection to port 6666 forwarding to localhost port 1337 requested.
debug1: channel 4: new [direct-tcpip]
debug1: channel 4: free: direct-tcpip: listening port 3333 for localhost port 66                          66, connect from ::1 port 49496, nchannels 5
debug1: channel 4: free: direct-tcpip: listening port 6666 for localhost port 13                          37, connect from 127.0.0.1 port 48808, nchannels 5
debug1: Connection to port 3333 forwarding to localhost port 6666 requested.
debug1: channel 4: new [direct-tcpip]
debug1: Connection to port 6666 forwarding to localhost port 1337 requested.
debug1: channel 4: new [direct-tcpip]
$ debug1: channel 3: free: direct-tcpip: listening port 3333 for localhost port 6666, conne               ct from ::1 port 49495, nchannels 5
debug1: channel 3: free: direct-tcpip: listening port 6666 for localhost port 1337, connect                from 127.0.0.1 port 48807, nchannels 5
$

リモートデスクトップ接続が確立されました。ご覧のとおり、devilsmilkduclawから来ているように見えます。しかし、kgraves-PCによると、それはDevilsmilkから戻ってきています。だから私が以前に起こっていたと思っていたのは実際にはそうではなかった。 DuclawRDPセッションを別のパスを介してkgravesに送り返していると思いましたが、そうではなかったことがわかりました。前回はうまくいったのか、別の設定をしたのか、それとも想像していたのかわかりません。しかし、sshサーバーで問題が発生した後、すべてを再構成してバックアップして実行したので、それは間違いなくもう行われていません。

enter image description here

これは、wiresharkセッション中にkgraves-pcで実行されているRDPです。

enter image description here

したがって、Duclawが完全に別個のリバーストンネルを介してRDPセッションをKgraves-pcに送り返すようにしたいという私の問題は依然として残っています。それは私が起こる必要があることであり、その方法を理解することはできません。

duclawを経由せずに別のトンネルで直接kgraves-pcに送り返すには、devilsmilkが必要なだけでなく、送信先のエフェメラルポートを制御する必要もあります。ランダムなエフェメラルポートではなく、ポート:44444に送信してほしい。上記の詳細なデバッグsshプリントアウトでランダムに:48809を使用しています。

うまくいけば、これで問題が解決することを願っていますが、そうでない場合は...さらに混乱させて申し訳ありません。

5
Kentgrav

リクエスト

悪魔の乳から来ているかのように「表示」するには、リモートデスクトップ接続が必要です。しかし、私はduclawが、devilsmilkを経由せずに、応答をkgraves-pcに直接返送することを望んでいます。したがって、kgraves-pcに対して、RDPセッションはローカルホストに送信され、ローカルホストはsshトンネルを介してdevilsmilkを介してduclawに転送されますが、その接続に応答して受信されるRDPパケットはDuclawから直接受信されます。

回答-TCP通信の性質上、実行できません

少なくともsshトンネルだけでは、それは実行可能ではないと思います。

必要な/要求されたパケットフローを見てみましょう。

  1. kgraves-pcは、devilsmilk:6666へのトンネルであるlocalhost:3333へのRDP要求を開始します
  2. devilsmilk:6666はduclawへのトンネル:1337
  3. duclaw:1337RDP応答パケットをkgraves-pcに送信

上記のパケットフローは、少なくとも通常の状況では発生しません。上記のフローについてもう少し詳しく説明します。

  1. kgraves-pcは、devilsmilk:6666へのトンネルであるlocalhost:3333へのRDP要求を開始します

    この時点で、kgraves-pc RDPクライアントは、localhost:3333からのリターンパケットを期待しています。

  2. devilsmilk:6666はduclawへのトンネル:1337

    この時点で、duclaw RDPサーバーへの要求はlocalhost(duclaw ifself)からのものであり、直接応答します。

  3. duclaw:1337RDP応答パケットをkgraves-pcに送信

    上記の(2)に基づいて、このパスはまったく発生していません。

元の回答(OPが望んでいるものではありません)

kgraves-pcで、OP要件を達成するためのトンネリングを使用したSSHコマンド。

ssh user@devilsmilk -L 3333:localhost:3389 -L 6666:10.0.10.130:3389 -R 23389:localhost:3389

-L 3333:localhost:3389localhost:3333を使用してkgraves-pcRDPをdevilsmilkに有効にします

-L 6666:10.0.10.130:3389 kgraves-pcRDPがlocalhost:6666でduclawできるようにします

-R 23389:localhost:3389devilsmilk:23389を使用してduclawRDPがkgraves-pcを有効にする

3
John Siu