Unable to SSH tunnel to hit private API

オープン
#430 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
node.js, typescript

調査の方向性

issue の例にある ssh.connection?.forwardOut から始め、コマンドライン SSH トンネルとその転送動作を比較します。node-ssh の転送 API を確認し、localhost:8081 への Axios リクエストを検証します。SSH セッションを開いたままプライベート API エンドポイントが応答すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

external unconfirmed bug

Hey all,

I have a server in a private subnet that is hosting a REST API on port 80 and a jump box in a public subnet that I would like to tunnel through so that I can invoke the REST API in the same execution with axios. When I run the command line command to tunnel everything works fine:

ssh -i "keypair.pem" -L 8081:<API HOST>:80 <JUMP BOX USER>@<JUMP BOX IP>

Once I run that command, as long as I keep the session open, I can hit the API through Postman/Axios. All good.

I am trying to do the same thing with this library, but the connection is not being exposed properly and I can't figure out why. Here is my code:

const ssh = new NodeSSH();
await ssh.connect({
  host: '<JUMP BOX IP>',
  username: '<JUMP BOX USER>',
  privateKey: `RSA KEY`
});
ssh.connection?.forwardOut('127.0.0.1', 8081, <API HOST>, 80);
const response = await axios.get(`http://localhost:8081/<ENDPOINT PATH>`);

The connection opens fine and I can exec commands as I want. This issue may be a result of using async/await as well, but I would like to stick using that model if possible.

Thanks in advance for the eyes and any ideas.

主要言語
TypeScript
スター
1k
フォーク
94
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

steelbrain/node-ssh のほかの issue

steelbrain/node-ssh の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。