Post #946994
2026-04-05 15:33 UTC
Replies (14)
-
@kevin@mastodon.km6g.us 2026-04-05 15:56
I'm going to punt on this, and just symlink the needed binaries/scripts into /usr/local/bin, which is already in the PATH.
-
@frank@frankwiles.social 2026-04-05 15:40
@kevin I think you need to add it to .bashrc
-
@ark_r@mastodon.social 2026-04-05 15:45
@kevin In Ubuntu it could be /etc/environment and/or /etc/security/pam_env.conf. But it is processed by pam, (man pam_env), so you probably have to set UsePAM yes in /etc/ssh/sshd_config. You can also add Environment option in ssh.service and define PATH for sshd process and it's children.
-
@krahabors@toot.lv 2026-04-05 15:49
@kevin Look up .bashrc - or /etc/bashrc
-
@ffeth@hostux.social 2026-04-05 15:50
@kevin "man bash" is still ok. Bash has an option for this, and this option has a default -so it's always active: --rcfile file Should point you to /etc/bash.bashrc or something (not on a computer right now)
-
@bryanredeagle@beige.party 2026-04-05 15:54
@kevin This is for Bash specifically. Each shell works a bit differently. For login shells (interactive or not), it runs `/etc/profile`, then `~/.bash_profile`, `~/.bash_login`, and `~/.profile`. For interactive non-login shells, it runs `~/.bashrc`. For non-interactive non-login shells, you have to set `BASH_ENV` to a script to run before you run Bash. You need to give the full path of the script, I think. If you are running a script or command over sshd (rather than logging in and interacting with commands as usual), it'll run `~/.bashrc`. Here's the doc page: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
-
@alienghic@timeloop.cafe 2026-04-05 15:54
@kevin Search for the invocation section of man bash. It lists the order the configuration files are processed in, /etc/profile should be first and for both interactive and non-interactive shells. Though something else later might override setting the PATH? Also you might also need to add an export PATH in in whatever script you change the path in.
-
@phragment@fosstodon.org 2026-04-05 16:19
@kevin This is probably a security measure by sshd. Try looking at its documentation.
-
@mason@partychickens.net 2026-04-05 16:19
@kevin In at least a couple of your replies you've talked about the default Debian .bashrc as though it's an immutable fact of life. Delete it! I keep everything in my .shrc and have my .profile source it. I get precisely the same environment everywhere, doing this. I use these same rc files everywhere. My .shrc sets the right prompt based on whether it's root or non-root. It also uses one pattern for PS1 in bash, since bash is buggy and can't count emitted characters correctly, and another for shells that don't have counting bugs - oksh for instance. There's no reason to stick with the defaults, and you can even set up custom skeletons so your new users get functional rc scripts from the start.
-
@AlanSill@mast.hpc.social 2026-04-05 16:45
@kevin This is a complicated question, more so than people think. Among many attempts to explain it that you have no doubt found is this one: https://linuxize.com/post/bashrc-vs-bash-profile/ but the short answer is there is no good way to do this for everything, you need to have your use case(s) in mind and mapped out and provide for each of them. Just when you think you've got it figured out, another comes along, so try, rinse, and repeat if needed.
-
@synlogic4242@social.vivaldi.net 2026-04-05 17:03
@kevin I've run into same pain. my two shotgun solutions: 1. always cite absolute path to your desired exe. so much BS goes away. DONE or 2. revise all those scattered env-setting config files so each one imports/sources a single specific common file (like in .sh format), under the hood, that ensures PATH has the path prefix in it, adding it if needed at beginning or end I don't think I've ever had 1 or 2 not suffice The problem with relying on PATH is that some code is also sensitive to its CWD/PWD at runtime. To extend the shotgun approach I sometimes force those env values too inside scripts, so they are less fragile
-
@ulrich@social.server17.net 2026-04-05 17:05
@kevin Here you can set systemwide variables: https://www.man7.org/linux/man-pages/man5/environment.d.5.html
-
@futuresprog@mastodon.nzoss.nz 2026-04-05 20:10
If you allocate a tty (ssh -t command) that should do your bash login and run all your dot files (same as bash -i or sudo -i command) I usually put things in .bashrc and have to check for a terminal before doing any output as that breaks rsync/scp/sftp if you have any output in there. @kevin
-
@joat@mastodon.scot 2026-04-05 20:13
@kevin I'm late to this party but in cases like this I try to reverse-engineer how it currently works. In this case I'd try finding out where the current path is set and put it in the same place: grep -r /usr/local/bin /etc