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

[FEAT] ssh access to container #128

Closed
1 task done
nemo701 opened this issue Oct 10, 2024 · 3 comments
Closed
1 task done

[FEAT] ssh access to container #128

nemo701 opened this issue Oct 10, 2024 · 3 comments

Comments

@nemo701
Copy link

nemo701 commented Oct 10, 2024

Is this a new feature request?

  • I have searched the existing issues

Wanted change

Given that beets is a command line program, would it be possible to add direct shell access to the docker container?

Reason for change

The docs says that you can connect to the docker container using docker exec -it -u abc beets bash, but that supposes you are running the container from the same machine that you are using when you want to run beets. Adding ssh access would allow you to run the container (and store its data) on a separate machine (eg on a home server).

I realise that you can ssh into the home server and then run the docker exec command from there, but it would be nice if there was an option to eliminate the extra step.

Proposed code change

Perhaps have additional environmental variables (SSH_USER, SSH_PASS) which, if set, enable sshd with those login details?

I've tried to add sshd to the container via custom-services.d and custom-cont-init.d, and while this works as far as allowing me to connect to the container, the beet command isn't available (it looks like the user who has connected via ssh is missing /lsiopy/bin from PATH - but if I add that manually to the PATH, beet config -e doesn't work ("error: Could not edit configuration: [Errno 2] No such file or directory"), so it feels like I'm missing something... assuming this is even a valid route to achieve what I'm looking for :) )

Copy link

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

@j0nnymoe
Copy link
Member

We have no plans to add SSH to our containers. We would assume if you're already deploying the container on the server that you'd have SSH access to said server. If you really must add SSH, you can manually add it via https://github.com/linuxserver/docker-mods/tree/universal-package-install and configure it yourself.

@j0nnymoe j0nnymoe closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
@LinuxServer-CI LinuxServer-CI moved this from Issues to Done in Issue & PR Tracker Oct 10, 2024
@nemo701
Copy link
Author

nemo701 commented Oct 10, 2024

Fair enough. Thank you for responding so quickly :)

In case it's useful to anyone else, I think I've got this working by -

  • installing openssh in the container (using docker environment variables of DOCKER_MODS=linuxserver/mods:universal-package-install and INSTALL_PACKAGES=openssh)
  • running ssh-keygen -A within the container
  • editing /etc/ssh/sshd_config to add PermitRootLogin yes
  • running passwd to set the root password
  • launching /usr/sbin/sshd

I can now connect to the container over ssh, but need to pass some environmental variables to the ssh session, which I do as follows -

bla="BEETSDIR=/config"
bla2="HOME=/config"
bla3="VIRTUAL_ENV=/lsiopy"
bla4="PATH=/lsiopy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin://usr/bin:/sbin:/bin"
bla5="_=/usr/bin/env"
bla6="EDITOR=nano"

ssh -t [email protected] -p 8338 "export $bla $bla2 $bla3 $bla4 $bla5 $bla6 && /bin/bash"

(substitute 8338 for whichever port you've mapped to port 22 on the container)

It feels a bit hacky, and I'm not certain that all of the exported variables are necessary (or if I've missed any), so feel free to suggest improvements. I just wanted to put this here in case it helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants