Use port from ssh config

I'm using Core Tunnel to have a GUI (and notifications) for my hosts setup in .ssh/config. The way I use it is I setup a custom (i.e. non-existing) Host in the config file (along with all the options I want, such as port forwards), then set the host (and nothing else) in Core Tunnel.
Now I can connect in Core Tunnel and see the status and everything, yet I can manage everything in my ssh-config (and use the hosts in many other tools supporting ssh as well).

This works great, except that Core Tunnel requires me to specify a port for every final connection.
See, I have a JumpHost setup like that:

Host local.dev
  HostName 10.0.1.1
  Port 22
  LocalForward 3000 10.0.1.240:3000
Host remote.dev
  HostName 0.0.0.0
  Port 44440
  ProxyJump jump.dev
  LocalForward 3000 10.0.1.240:3000
Host jump.dev
  HostName whatever.dev
  Port 22
  IdentitiesOnly yes
  Compression yes

Using local.dev in Core Tunnel works fine when I setup Port 22, no worries here.
But for remote.dev I have to specify port 44440 even though it's already specified in the config. In the above example this is not a real problem, I can just set it up in Core Tunnel and everything is fine.
But as I have quite a few hosts I want to connect to locally when I'm in the same network I have a lot of hosts setup like this:

Match Host test.dev exec "/bin/bash %d/.ssh/scripts/check-host-fingerprint.sh 10.0.1.1 SHAKEY"
  HostName 10.0.1.1
  Port 22
  LocalForward 3000 10.0.1.240:3000
Host test.dev
  HostName 0.0.0.0
  Port 44440
  ProxyJump jump.dev
  LocalForward 3000 10.0.1.240:3000

This way, the connection to 10.0.1.1 is used when I am on the same network, while the jump via jump.dev is made when I'm not.
Core Tunnel handles this perfectly and everything works, except for the port. No I have to specify a port in the connection so I put in 22 - but when the proxy jump is used, I would need to use 44440 (as specified in the config), yet Core Tunnel overrides this and the connection fails.
Using the generated equivalent ssh command works totally fine btw, so this is not a problem of ssh internally.

I guess if you were to parse the port from .ssh/config instead of forcing me to enter one myself, this would actually also work just fine.

Thanks in advance for any pointers!

Thank you very much for describing this issue in detail. May be we should make Port optional in profile settings of Core Tunnel, will investigate this possibility for sure.

Kindly Regards,

Yang


Just a remind for myself, any changes on this may affect this ticket:

Maybe I'm missing something but why don't you chain the proxyJump hosts? You only need on config entry. I do this with both Core Shell and Core Tunnel

https://www.ateam-oracle.com/post/simplify-your-day-with-ssh-config-file-entries-and-self-closing-tunnels

I can't chain them easily, because at some days test.dev is actually reachable directly for me (i.e. I'm in the same network) and I want to connect to it directly (to save bandwidth and also so traffic does not leave the network). I only want to connect via jump.dev when test.dev is not reachable locally.

With pure ssh this works fine, it'll use the Port from the last Host-Directive it finds (which, if I understand correctly, is also the expected behaviour of ssh). It's just that Core Tunnel will instead use the Port specified in the config of Core Tunnel, overriding my ssh config and failing to connect.

I believe making it possible to not specify a port as @yang said might actually solve the problem. To keep it simple, maybe we can explicitly specify "-1" as a way to tell core tunnel to use the port from ssh config?

Or you can simply have a couple of different entries in your config file. I have that since having an ssh session open with added ports will fail if the same entry is already used by any other session using that entry. You can also have some logic in the config entries that will dynamically see if an internal address is directly available rather than jumping, Tunneling an SSH connection only when necessary using Match (solving your overall issue)

Thanks for the suggestion, but that's exactly what I'm doing - see my first post, 2nd code block.

Matching works perfectly if I use plain ssh - yet when using Core Tunnel it'll override the port, this is why I've opened this thread in the first place.

Sorry, sloppy reading on my part. Am I reading it correctly that you do specify a port in Core Tunnel in addition to referencing ssh/config? In my setups I omitted that and only use the ssh/config so there is no other port for Core Tunnel to use.

No worries. How do you not specify a port? If I create a connection, Core Tunnel forces me to specify a port, I cannot not leave that field blank. Any pointers how you do this?

I was referring to ports forwarded. You can leave that section empty and ports defined in ssh/config will be used. Obviously you need a port for the connection itself. So if you have two entries to auto connect then one will fail sometimes in your situation. One problem remains though if both works and have the same ports forwarded...one connection will fail because the port is already taken. So I agree, some logic in Core Tunnel is need to test a connection and use an alternative if the test fails.

Actually, since Core Shell and Tunnel honors Config entries why do you need to specify a port in the settings? The port is already specified in the config entry...

Would you mind telling me how to set up Core Tunnel so that it uses the port from config for connecting? I was not able to get this to work, thus I've created this ticket.

This is the core tunnel setup, no forwarded ports. Just the ssh port that I question why it's needed

Since it's specified in the config entry with port 19999 forwarded

config