SJBERTRAND / portforwarding-extension

Gnome Extension for port forwarding via SSH
GNU General Public License v3.0
1 stars 0 forks source link

Feature: Multiple port-forwardings #3

Closed mueckinger closed 1 month ago

mueckinger commented 2 months ago

User story: As a user I have multiple port-forwardings and can switch each of them on/off via the tray icon. There is a possibility to manage the "Connection settings" for each port-forwarding.

SJBERTRAND commented 2 months ago

I'll have to look into this. Would something like the following works. You can provide a list multiple ports on the host and multiple port on the remote and by connecting to the server all port specify would be forwarded.

For example: remote port: 22 500 8080 host port: 8022 8500 8080

When connecting the remote port 22 would be map to port 8022 on the host, remote port 500 to port 8500 on host and remote port 8080 to port 8080 on host.

mueckinger commented 2 months ago

Sorry, for being imprecise. With multiple port-forwardings I did not mean multiple ports (to the same host). I was thinking of multiple connections (or SSH tunnels) possibly to different hosts. So this would mean being able to manage multiple connections. As an example below a screenshot from another gnome-extension called "rclone-manager" where I have configured two connections "nuc" and "shared" in my case, which I can turn on/off or manage via the tray icon. Bildschirmfoto vom 2024-08-20 20-58-11

SJBERTRAND commented 2 months ago

ok I get it now. I can try to see if I can make it work. It will take me some time. I do this as a hobby and there is some technical issues I need to figure out first. For example the Gio.Settings glib schemas need to have pre defined variables name to store values such as the port number for each connection. You suggestion will required dynamic entries which might not be possible. I could make a predefined range of value that can be stored which will limit the number of available connections. Just to give me an idea, how many different connections do you think you need?

mueckinger commented 2 months ago

Possibly 5 different connections?

SJBERTRAND commented 2 months ago

Hi I have a working prototype. It actually accept 5 servers connection and each server can have multi-ports connection. In the initial testing everything is working properly. I will continue through the week to see if I can find any bugs and if I can't find any I will upload it to the gnome-extension website. In the mean time feel free to take it for a spin. Just remove the old version then download the new portforwarding-extension@SJBERTRAND.github.com.shell-extension.zip from github and install it with $ gnome-extensions install ./portforwarding-extension@SJBERTRAND.github.com.shell-extension.zip if you have issues with it just uninstall it with $ gnome-extensions uninstall portforwarding-extension@SJBERTRAND.github.com and reinstall the one from the gnome-extension website.

Obviously not a bad thing to look at the code first. If you try it let me know what you think.

SJBERTRAND commented 2 months ago

Don't click on those blue link they were created automatically and it send an email to that address which is not an actual email address. I forgot you can try the extension in a virtual machine if you are not sure or don't want to remove the current version from your machine.

SJBERTRAND commented 2 months ago

I fixed some bugs this morning. Still need to work on a notification system when connection fails.

mueckinger commented 1 month ago

Hi, I just tested Version 4 but I get an ssh usage error. Maybe a misconfiguration? ssh manual says: ssh -L [bind_address:]port:host:hostport destination I cannot figure out the mapping between extensions variables and the ssh variables.

SJBERTRAND commented 1 month ago

Ok I tried the extension on a brand new installation of ubuntu 24.04LTS and had no issues. Ensure the following

1- sshpass is installed (not install by default on ubuntu) its needed if you want to use a passwords instead of a key file $apt install sshpass

2- If you are using a password use the switch to use password

image

3- Test your connection first in a terminal. It will also initiate the first handshake which is required for further connection and will ensure that you can actually connect to the server.

4- For multiple ports use a space in between each ports. note that they will bind in the order they are written. In this example 80 will bind to 8080 and 443 will bind to 8443

image

Let me know if it's doesn't work.

mueckinger commented 1 month ago

Ok I've found the issue. It seems providing the username is mandatory in the extension. This is different from ssh behaviour which defaults to the local username if not provided. Now it works. Great work.