Unable to SSH tunnel to hit private API
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- node.js, typescript
- Domain
- backend, networking
Research direction
Start at ssh.connection?.forwardOut in the issue's example and compare its forwarding behavior with the command-line SSH tunnel. Check the node-ssh forwarding API and verify the localhost:8081 Axios request; done means the private API endpoint responds while the SSH session remains open.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from steelbrain/node-ssh
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
steelbrain/node-ssh#487 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
steelbrain/node-ssh#482 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
steelbrain/node-ssh#474 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
steelbrain/node-ssh#473 · 1 comment · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
steelbrain/node-ssh#472 ·
All issues in steelbrain/node-ssh
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
cli: `execCargoMetadata` decodes stdout per chunk, corrupting non-ASCII paths across pipe boundariesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 62/100
lingdojo/kana-dojo#34127 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
osmlab/name-suggestion-index#13104 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100