Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use a login shell for coder ssh#18805

evilhamsterman started this conversation inFeature Requests
Discussion options

Write now it looks like the coder agent handles a lot of the environment setup when connecting ssh. However this creates limitations, especially when connecting to full system environments like VMs. It does not initialize things like.profile, and on systems with systemd things like DBUS are not initialized preventing usage of things like systemd user services or environment configuration through systemd

Shell to a VM with regular SSH or Tailscale

❯ systemctl --user list-units -t service  UNIT              LOAD   ACTIVE SUB     DESCRIPTION  dbus.service      loaded active running D-Bus User Message Bus❯ env|grep DBUSDBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus

Shell to same VM through coder

❯ systemctl --user list-units -t serviceFailed to connect to bus: No medium found❯ env|grep DBUS❯ echo $?1

Rather than start the shell directly you should use thelogin orsu commands, these are available even in most containers, and only fall back to directly starting the shell if necessary.

❯ docker run --rm -it ubuntu:nobleUnable to find image 'ubuntu:noble' locallynoble: Pulling from library/ubuntub08e2ff4391e: Pull completeDigest: sha256:440dcf6a5640b2ae5c77724e68787a906afb8ddee98bf86db94eea8528c2c076Status: Downloaded newer image for ubuntu:nobleroot@8fbce12dd944:/# type loginlogin is /usr/bin/loginroot@8fbce12dd944:/# type susu is /usr/bin/suroot@8fbce12dd944:/# exitexit❯ docker run --rm -it alpine shUnable to find image 'alpine:latest' locallylatest: Pulling from library/alpineDigest: sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715Status: Downloaded newer image for alpine:latest/ # type loginlogin is /bin/login/ # type susu is /bin/su

This is the same thing that occurs when you login from a terminal or through SSH, it takes care of changing to the $HOME directory, runs PAM to setup things like DBUS or pam_mkhomedir, etc.

You must be logged in to vote

Replies: 2 comments

Comment options

I think the dbus thing is happening because Tailscale is started by systemd, whereas in most situations Coder is started through an init script or cloudinit.

You must be logged in to vote
0 replies
Comment options

No on our VMs Coder is also started by Systemd.

❯ systemctl status coder-agent.service● coder-agent.service - Coder Agent     Loaded: loaded (/etc/systemd/system/coder-agent.service; enabled; preset: enabled)     Active: active (running) since Wed 2025-07-09 10:13:50 PDT; 2min 46s ago   Main PID: 1091 (coder)      Tasks: 134 (limit: 19095)     Memory: 1.2G (peak: 1.3G)        CPU: 29.923s     CGroup: /system.slice/coder-agent.service             ├─ 1091 ./coder agent             ├─ 1980 filebrowser             ├─ 2898 sh /tmp/vscode-web/bin/code-server serve-local "" "" --port 13338 --host 127.0.0.1 --accept-server-license-terms --without-connection-token --t>             ├─ 2902 /tmp/vscode-web/node /tmp/vscode-web/out/server-main.js serve-local "" "" --port 13338 --host 127.0.0.1 --accept-server-license-terms --without>             ├─ 6617 /bin/fish -c sh

The DBUS I'm referring to is specific to user sessions and is started by the login process.

It is typically started bypam_systemd which is only started when PAM is run which only happens on login not just when you run the shell.

You can see the difference in name of the process for Coder vs Tailscale and OpenSSH. Launching the shell as-<shell> indicates it's a login shell not just an interactive shell

Coder

❯ ps %self    PID TTY      STAT   TIME COMMAND 167241 pts/4    Ssl    0:00 /bin/fish

Tailscale

❯ ps %self    PID TTY      STAT   TIME COMMAND   5833 pts/1    Sl     0:00 -fish

OpenSSH

❯ ps %self    PID TTY      STAT   TIME COMMAND 160349 pts/2    Ssl    0:00 -fish
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
2 participants
@evilhamsterman@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp