Skip to content

Basic ssh_config support #15499

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

Merged
merged 6 commits into from
Apr 28, 2025
Merged

Basic ssh_config support #15499

merged 6 commits into from
Apr 28, 2025

Conversation

KnowZero
Copy link
Contributor

What it does

Very basic support for ssh_config files and quick access to ssh_config hosts.

Currently only Host, Hostname, Port, User, and IdentityFile is supported. With Host allowing some wildcards which can be accessed through %h

How to test

Step 1:

Create an sh file with the following and run it, it will generate a ssh_config file and docker files and ssh keys to test with:

#!/bin/bash

# create docker-compose file
cat > ./docker-compose.yml << EOF
version: '3.8'
services:
    theia_ssh1:
        build:
            context: .
            args:
                SSH_PORT: "2221"
        ports:
            - 2221:2221
EOF

# create docker file with ssh server
cat > ./Dockerfile << \EOF
FROM ubuntu:latest
ARG SSH_PORT
RUN  mkdir ~/.ssh && apt-get update && apt-get install -y openssh-server xz-utils


COPY ./id_rsa.pub /root/.ssh/authorized_keys
RUN mkdir /var/run/sshd
RUN echo 'root:password' | chpasswd


RUN echo "PORT=${SSH_PORT}" \
    && sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
    && sed -i "s/#Port 22/Port ${SSH_PORT}/" /etc/ssh/sshd_config

    
CMD ["/usr/sbin/sshd", "-D"]
EOF

# create ssh_config file file
cat > ./ssh_config << EOF
Host localhost
    Port 2221
    User root
Host test1
    Hostname 127.0.0.1
    Port 2221
Host test2_*
    Hostname %h.0.0.1
    Port 2221
Host test3_?
    Hostname 127.0.0.%h
    User root
    Compression yes
    Port 2221
Host test4
    Hostname 127.0.0.1
    Port 2221
    IdentityFile ${PWD}/id_rsa 

EOF

#generate key
ssh-keygen -t rsa -f "${PWD}/id_rsa" -q -P ""

Step 2:

set remote.ssh.configFile setting to point to config file generated

Step 3:

docker-compuse up

Step 4:

When connecting to remote host, you can either access them via typing like test1 or pick it in the quick access menu(Connect Current Window to Host in Config File). You can also do things like root@test1, default password is password. You can also test wildcard via root@test2_127 , test3_1 shows single character wildcard and test4 is key login without password

Follow-ups

Partly fixes #14102 and #14289

@jonah-iden

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

@github-project-automation github-project-automation bot moved this to Waiting on reviewers in PR Backlog Apr 22, 2025
@msujew msujew requested a review from jonah-iden April 22, 2025 21:33
@jonah-iden
Copy link
Contributor

Hi, thanks for the contribution. It works great. I left a few suggestions.
Also it seems you havn't signed the eca yet. Would be great if you could do that otherwise we can not merge this for legal reasons

@KnowZero
Copy link
Contributor Author

Hi, thanks for the contribution. It works great. I left a few suggestions. Also it seems you havn't signed the eca yet. Would be great if you could do that otherwise we can not merge this for legal reasons

I definitely signed it, same way I signed it before. It's weird/ Clicking it, it seems the sign verification is down?

@jonah-iden
Copy link
Contributor

I definitely signed it, same way I signed it before. It's weird/ Clicking it, it seems the sign verification is down?

I was also under the asumption you did.
Doesn't seem to be down. I revalidated it and still seems to fail.
When you look at https://api.eclipse.org/git/eca/status/gh/eclipse-theia/theia/15499 ther are some troubleshooting steps, could you check those

@jonah-iden
Copy link
Contributor

jonah-iden commented Apr 24, 2025

Doesn't seem to be down. I revalidated it and still seems to fail.

sorry i take that back. There actually seems to be a problem at eclipse right now with the eca validation

@KnowZero
Copy link
Contributor Author

Doesn't seem to be down. I revalidated it and still seems to fail.

sorry i take that back. There actually seems to be a problem at eclipse right now with the eca validation

Validation seems to be fixed so I revalidated it

@KnowZero
Copy link
Contributor Author

KnowZero commented Apr 27, 2025

@jonah-iden Okay, I implemented ssh-config

Copy link
Contributor

@jonah-iden jonah-iden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a few smaller improvements for the usage of SSH config. Hope that was ok. But this looks good to me now.

@github-project-automation github-project-automation bot moved this from Waiting on reviewers to Needs merge in PR Backlog Apr 28, 2025
@jonah-iden jonah-iden merged commit 332ed98 into eclipse-theia:master Apr 28, 2025
7 of 11 checks passed
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Apr 28, 2025
@github-actions github-actions bot added this to the 1.61.0 milestone Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Unable to connect via SSH with keyfile
2 participants