VSCode remote-ssh extension: server-side port [duplicate] - visual-studio-code

I discover Visual Studio Code Remote Development Extension Pack. I wanted to try it, but my remote is on a 2222 port.
I can correctly connect with Putty and my port 2222, same on my Linux laptop with ssh command.
What is the correct config to use Code Remote via SSH with other port ?
Thanks
Host my-remote-connection
HostName mydomain.name
User myusername

Just add Port to your config like:
Host my-remote-connection
HostName mydomain.name
User myusername
Port 2222

Related

How to respond to terminal prompts when connecting vscode ssh

I'm trying to use ssh to connect vscode to a HPC. Unfortunately to connect I need to use a jump host which prompts for the forward connection.
ssh config
Host <JUMP_HOST_IP>
HostName <JUMP_HOST_IP>
User MYUSER
ControlMaster auto
ControlPath ~/.ssh/%r#%h:%p
Host <TARGET_IP>
Hostname <TARGET_IP>
ProxyJump <JUMP_HOST_IP>
User MYUSER
Attempting to connect then displays the prompt Enter host or service name: in the ssh output terminal but as vscode attempts to install I just get the following error: Enter host or service name: Bad format host name

VS code SSH tunnel

I have question about ssh tunnel in VS code. I am using for connecting to remote machine Remote - SSH extension. My setup now is: putty for connecting to server, in Putty after it is created Tunnel to next point.
PUTTY -> someIP -> polaris:22 (tunnel)
Putty create tunnel to polaris on localhost:4000. After it, I can use VS code with remote SSH to localhost:4000 and it working fine.
Is in this extension some possibility to create SSH tunnel directly without using putty? :)
I got the answer from https://superuser.com/questions/1528212/vscode-ssh-with-multiple-hops
In my case I'm using VSCode in windows to connect to several linux machines from the organization net and from outside the organization via an ssh tunnel.
In my configuration file remoteSsh.configFile I have the following configuration.
Host machineName1 (to connect from inside organization)
HostName [machineName1.organization_internal_extension]
Port [portNumber for ssh]
User [Username]
IdentifyFile [local path to ssh key]
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes
Host machineName2 (to connect from inside organization)
HostName [machineName2.organization_internal_extension]
Port [portNumber for ssh]
User [Username]
IdentifyFile [local path to ssh key]
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes
Host tunne_machineName1 (to connect from outside organization)
HostName [machineName1.organization_internal_extension]
Port [portNumber for ssh]
User [Username]
IdentifyFile [local path to ssh key]
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes
ProxyJump machine_tunnel
Host tunne_machineName2 (to connect from outside organization)
HostName [machineName2.organization_internal_extension]
Port [portNumber for ssh]
User [Username]
IdentifyFile [local path to ssh key]
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes
ProxyJump machine_tunnel
Host machine_tunnel( machine to jump)
HostName [machineName.organization_internal_extension]
Port [portNumber for ssh on tunnel machine]
User [Username]
IdentifyFile [local path to ssh key]
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes
The X11 forward is not mandatory.
Hope this helps
Put the following information into your local machine's /.ssh/config:
Host [1]
HostName [2]
User [3]
Port [4]
Substitute [1], [2], [3], and [4] with a host name you prefer, the IP address of the host, the user name you log in the remote server, and the localhost port assigned to you.
For example,
Host VM1000
HostName 123.45.678.9
User root
Port 4000
Then you can just click the Remote Explorer icon in VS Code and click the VM1000 entry to connect your local machine to the remote server.
Hope this resolve your connection problem.

SSH Tunnel for MongoDb Connection Within VPC

I am attempting to tunnel from my localhost (on port 24000) via a Bastion box to my mongo instance (on 27017) that is only available via the VPC private subnet so that I may develop locally whilst connected to the staging db. Using this tunnel command on my OSX box:
ssh -A -L 24000:ip-10-0-11-11.ec2.internal:27017 ec2-3-211-555-333.compute-1.amazonaws.com -N -v
"ip-10-0-11-11.ec2.internal" is the mongo box.
"ec2-3-211-555-333.compute-1.amazonaws.com" is the bastion box.
Aiming to bind local port 24000 to the bastion then from there to the mongo box on 27017.
However upon trying to connect via the tunnel from my local box with:
mongo -u dbUser localhost:24000/db-name
The connection is timing out. Below is the verbose output from ssh tunnel command (presumably from the bastion?).
debug1: channel 3: free: direct-tcpip: listening port 24000 for ip-10-0-11-11.ec2.internal port 27017, connect from 127.0.0.1 port 63451 to 127.0.0.1 port 24000, nchannels 4
channel 4: open failed: connect failed: Connection timed out
Seems to try to be working but it is just not. Any and all help would be appreciated! I do have ssh forwarding enabled on the bastion via the sshd config. I can also connect to the mongo instance while on the bastion no problem.
Circling back... not sure how I got it working or why it wasn't working, but for those looking forward the ssh command to open a tunnel forwarding the keys in your ssh-agent this command is indeed the way todo.
ssh -A -L 24000:ip-10-0-20-141.ec2.internal:27017 ec2-54-165-159-177.compute-1.amazonaws.com -N -v

SSH Jump Host via Eclipse

I have the following environment configuration:
Client -> HOST_A (public IP address) -> HOST_B (private IP address)
That being said, to avoid connecting manually to HOST_A and then to HOST_B, I'm using the jump host configuration below in the .ssh/config file.
Host HOST_B
ProxyCommand ssh -q HOST_A nc -q0 HOST_B 22
This solution works well when I'm using a regular terminal, but it doesn't work when using "Remote Systems" in Eclipse IDE. I'm not sure if I have to enforce the config file or how to configure jump hosts in Eclipse.
Does anyone have an idea how to sort this out in Eclipse?
What about an ssh tunnel?
ssh -L 2222:HOST_B:22 -N HOST_A
Then you can use localhost:2222 to connect to HOST_B with ssh. You just need Eclipse to allow you to specify a port in the ssh configuration.

PostgreSQL SSH port forwarding via Windows/PuTTY

I have PostgreSQL 9.4 running on a Linux VPS, and I need to be able to connect to it over SSH from both Linux and Windows clients. (I will later need to connect to multiple servers, and so that all clients use the same port numbers, I'm forwarding to port 5551 for the first server, then I will use 5552, 5553, etc.)
From a Linux client I just run ssh -fNg -L 5551:localhost:5432 user#remote1.com and connect to localhost:5551 with PGAdmin3 or any other client app. Works great.
On Windows, I'm using PuTTY and Pageant. I got the connection to user#remote1.com via terminal working, then I went to the SSH Tunnels and added L5432 localhost:5551. Terminal connection still works, but when I try to connect with PGAdmin3 to localhost:5551 I get an error:
could not connect to server: Connection refused (0x0000274AD/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5551?
I resolved it. Like many things, this is obvious in hindsight. I had things backward in the SSH Tunnels setup in PuTTY. It needs to be L5551 remote1.com:5432