Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support openssh config files for remote consoles #22464

Open
gb119 opened this issue Sep 7, 2024 · 3 comments
Open

Feature request: support openssh config files for remote consoles #22464

gb119 opened this issue Sep 7, 2024 · 3 comments

Comments

@gb119
Copy link

gb119 commented Sep 7, 2024

So the remote console feature in Spyder 6 seems like a nice idea, but there are some more complex setups that I think could be supported if it was possible to point Spyder to an openssh config file. For example, my IT department make me proxy through an ssh host to get to the VMs where I'd like to connect a remote console.
If I've read the source code correctly, spyder is using asyncssh and that does provide at least partial support for config files by passing a config=.... parameter in connect().
So the request would be to add an optional Config File parameter to the manage remote connections dialog box, to tweak the testing of valid host names to allow profiles in the config file (maybe just don't validate the host if the config file option is given) an then use the config=.... parameter when doing the connection).
(I'd offer a PR myself, but I'm not sure my Python GUI coding is really up to making a usable PR in a sensible time frame!)

@gb119
Copy link
Author

gb119 commented Sep 7, 2024

....and when I read the source code a bit longer is see...

spyder/plugins/remoteclient/widgets/connectiondialog.py

    # TODO: The config file method is not implemented yet, so we need to
    # disable it for now.

So I guess this is a feature request that is on it's way, right?

@ccordoba12
Copy link
Member

So I guess this is a feature request that is on it's way, right?

That's right, the UI to pass ssh config files to Spyder is already there. I just didn't have enough time to implement that functionality in the backend.

Could you provide an example config file to take a look at it? It doesn't need to contain private info, of course. I just need it to understand how to parse it for asyncssh.

@gb119
Copy link
Author

gb119 commented Sep 7, 2024

So this is a slightly obfuscated OpenSSH config file that illustrates the use of ProxyCommand to use one ssh host to proxy into another. (In practice my instutition has a slightly more complex setup where either I use a VPN and then go to the proxy ssh server, or I go through another layer of ssh Proxy with an enforced interactive 2FA step - but that is definitely going to be out of scope for Spyder!).

A super quick test of asyncssh sugests that it can handle and work with these config file settings to make and run a connection. In the Spyder UI I'd want to be able to set the path to the config file and also the profile name to use::

host labserver
hostname=########.leeds.ac.uk
User ##########
ServerAliveInterval 30
ForwardAgent yes
compression=yes
ForwardX11=yes
ForwardX11Trusted=yes

host teaching
hostname 10.#.#.#1
User ##########
ServerAliveInterval 30
ForwardAgent yes
ProxyCommand ssh labserver-W %h:%p
# Alternative Proxy setup
# ProxyJump labserver
compression=yes
ForwardX11=yes
ForwardX11Trusted=yes

host phas-vitals
hostname 10.#.#.#2
User ##########
ServerAliveInterval 30
ForwardAgent yes
ProxyCommand ssh labserver-W %h:%p
compression=yes
ForwardX11=yes
ForwardX11Trusted=yes

Looking at asynssh, it seems if you do a:
cfg=asyncssh.config.SSHClientConfig.load(None,config_filepath, True,"user",remote_username,profile_name,remote_port)

then cfg.get_options(False) returns a dict that can be checked to see if it makes sense. A quick experiment suggests that if profile_name is not a valid profile, the dict will just have keys for User and Port, otherwise if the profile is valid the dict will have additional keys - so that at least lets spyder check that the profile name in the config file is valid. (It also implies that the spyder UI will need to ask for the config file path, profile name, user and port - despite the fact the profile might contain the username and port already!

@ccordoba12 ccordoba12 modified the milestones: v6.0.2, v6.0.3 Oct 9, 2024
@dalthviz dalthviz modified the milestones: v6.0.3, v6.0.4 Dec 6, 2024
@ccordoba12 ccordoba12 modified the milestones: v6.0.4, v6.0.5 Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants