Score:-1

How can I setup an SSH tunnel from local Windows 10 to remote Ubuntu?

vn flag

I have installed Visual C++ 2015 for Linux. What this does is, it takes a server name, a port number, a username, and a password, then connects to the remote machine, compiles a C++ program inside that machine, and then returns the result to my local PC.

enter image description here

Now, the problem I am facing is, I have to connect to the remote PC through a bastion-host machine.

Suppose, the IP address and port number of the bastion server are yyy.yy.y.20 and 8081 respectively; the IP address of the remote machine is xxx.xxx.x.180 but I don't know the port number.

What should be the command to create a tunnel from my local Windows 10 to the remote Linux machine?

ssh -L 22:xxx.xxx.x.180:22 yyy.yy.y.20:8081

The above command is giving me an error message:

Microsoft Windows [Version 10.0.19045.2846]
(c) Microsoft Corporation. All rights reserved.

C:\Users\pc>ssh -L 22:xxx.xxx.x.180:22 yyy.yy.y.20

C:\Users\pc>ssh -L 22:xxx.xxx.x.180:22 yyy.yy.y.20:8081
ssh: Could not resolve hostname yyy.yy.y.20:8081: No such host is known.

C:\Users\pc>

How can I setup an SSH tunnel from local Windows 10 to remote Ubuntu?

Score:2
in flag

the openssh client does not support the hostname:port scheme. Use -p instead.

ssh -L 22:xxx.xxx.x.180:22 -p 8081 yyy.yy.y.20
user366312 avatar
vn flag
Then what should I write on the VC++ Linux connection interface?
in flag
to connect to the tunnel? `localhost`?
user366312 avatar
vn flag
what would be the port, username, and password?
in flag
You defined the port `22` in the `-L` paramater. So it seems logical to use the port 22.
user366312 avatar
vn flag
username, password?
in flag
How should I know? ask whomever is responsible for the server you want to log in to.
user366312 avatar
vn flag
I mean: is it Windows username password, or the Bastion server username password, or remote host username and password?
in flag
The remote host of course.
user366312 avatar
vn flag
One more issue. The bastion-server actually doesn't ask for any password. I have to use a public key to connect to it. In that case, how should I modify the command?
in flag
Have you tried `ssh --help`?
user366312 avatar
vn flag
Yes, I tried. But, I didn't understand anything. Coz, my understanding of this matter is close to none.
Score:1
pg flag

To create an SSH tunnel from your local Windows 10 machine to the remote Ubuntu machine through the bastion-host machine, you can use the following command:

ssh -L <local_port>:<remote_ip>:<remote_port> <bastion_username>@<bastion_ip> -p <bastion_port> -i <path_to_bastion_private_key>

In your case, the command would look something like this:

ssh -L 2222:xxx.xxx.x.180:22 [email protected] -p 8081 -i path/to/bastion/private/key

Here's what each parameter in the command means:

  • -L: Specifies the local port forwarding. In this case, we're forwarding the local port 2222 to the remote Ubuntu machine's SSH port (22).
  • <local_port>: The port number on your local machine that you want to forward traffic to. In this case, we're using 2222.
  • <remote_ip>: The IP address of the remote Ubuntu machine you want to connect to.
  • <remote_port>: The port number of the remote Ubuntu machine's SSH service.
  • <bastion_username>: The username you use to connect to the bastion-host machine.
  • <bastion_ip>: The IP address of the bastion-host machine.
  • -p: Specifies the port number to connect to on the bastion-host machine. In this case, we're using 8081.
  • -i: Specifies the path to the private key file for the bastion-host machine.

Once you run the command, you'll be prompted for the password for the bastion-host machine's username. Once you enter the correct password, the tunnel will be established and you can use your Visual C++ 2015 for Linux to connect to the remote Ubuntu machine through the tunnel using the address localhost:2222.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.