Connect to server using ssh with -L flag?

Hello!

I'm a long-time user of Core Shell through Setapp. I've really enjoyed it; without a doubt it's the nicest SSH client I've ever used.

Question: How do I issue a custom ssh -L command to a saved host in Core Shell?
I cannot figure out how to specify arguments to the -L flag when I'm saving host in Core Shell. Please help.

I need to set a saved host to do this when it connects:

ssh user@Server -L localPort:localHost:serverPort

Scenario:

  1. There is a service on my Server listening at port 601 for a local connection from inside the Server. It does not accept remote connections.

  2. Using the -L flag, I ssh in to Server, specifying that port 100 on my Local Machine forwards to port 601 on Server.

  3. Then, on the Local Machine, I open Application, and point it at port 100 on Local Machine, which is forwarded over SSH to port 601 on Server.

This all works, but I have to do it in Apple's Terminal.app.

Hi John, Core Shell doesn't provide direct means to create port forwarding, I suggest two alternatives:

  1. Go and get Core Tunnel from App Store, and copy then paste the host from Core Shell, at last create a local port forwarding.

  2. Edit your ~/.ssh/config file, and add a LocalForward directive for the host.

Let me know if you need assistance.

Yang

Yang,

Hello! Thank you for your message. CoreShell is the best terminal app I’ve used on a Mac, and now I can add excellent technical support to the reasons why. :slight_smile:

I think I’ll go with option 2 for now. I’ve read some help files for LocalForward, and I’m going to try setting up the config file soon. Am I correct that the argument for the LocalForward direct is the same argument I’d pass to the -L flag on the command line?

Thanks again!

  • John.

Not exactly the same, here is an example for you:

Host Server
  LocalForward 0.0.0.0:100 localhost:601

Since port 100 is a privileged port, you HAVE TO set bind address to 0.0.0.0, please read this post for more details about privileged port:

@yang: Thanks again!

I chose bad hypothetical values, it seems. I didn't realize port 100 was privileged when I wrote my OP. I'm actually somewhere up in the thousands. :slight_smile:

In case it's helpful to anyone else, I ended up doing this:
Host Server
LocalForward PortOnServer 127.0.0.1:PortOnClientMachine

If I just use "localhost" instead of the IPv4 address, is ssh smart enough to use the device's IPv6 address if available? (All the machines on my local LAN have IPv6 addresses).

It depends on operating system implementation if you do not force ssh chooses one.

I didn't do any test on it, but according a cite in this article, macOS would prefer IPv6 address:

Mac OS X prefers IPv6 if a DNS query results in IPv4 and IPv6 addresses being sent back (A and AAAA RRs).

You can enable debug log to confirm this, Core Shell would print actual IP address on connecting:

I got distracted for a while from trying this, and I guess I have my dunce cap on.

I've verified the VNC server is listening, but the LocalForward does not seem to be working.
It's not showing up as an open port when I portscan my localhost address.

theHost has a static IP from my router.
LocalPort is over 1000.

I've got this:

Host theHost
HostName 192.168.1.99
LocalForward localhost:localPort 192.168.1.10:5901

What am I doing wrong? Do I need to restart the Mac? I terminated the SSH connection and reconnected, but with no effect.

Thanks again for your help.

Hi John, please try changing your config to this:

Host 192.168.1.99
LocalForward localhost:localPort 192.168.1.10:5901

If you still could not make it to work, please enable logging and send me the log output: