Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
4.33k stars 579 forks source link

Standard user's shell and colour settings #2155

Closed vtacquet closed 1 year ago

vtacquet commented 3 years ago

Is there a reason why using the Terminal in MeshCentral does not use the user's shell settings and 'environment' ?

When logging on with a normal SSH terminal client the shell is zsh and has colours image

When logging on with MeshCentral Terminal the shell is bash and has no colours image

User has zsh as default shell image

krayon007 commented 3 years ago

Right click on the connect button, and select login shell. That will use the user profile settings.

vtacquet commented 3 years ago

image

that just goes 'denied', only root shell and login shell works (but that defaults to bash), can you set it default to what is in the user settings ?

krayon007 commented 3 years ago

What linux distro are you using? I cannot set it to use the user profile because only the login shell can do that, which is what that other option is for. If you tell me what distro you are using I can try and figure out why the login shell isn't working.

vtacquet commented 3 years ago

well it is a bit of a special case, an "ubuntu:latest" in a docker container, it is used for testing.

krayon007 commented 3 years ago

I assume you meant only root and user shell is working? Login shell spawns a login process which root and user shells do not.

vtacquet commented 3 years ago

image the green ones work but give a colourless bash shell. the red one gives a denied

krayon007 commented 3 years ago

The login shell spawns a login process which is supposed to read the user profile. Is it prompting for a user name and password?

vtacquet commented 3 years ago

yes image

krayon007 commented 3 years ago

That's interesting. Normally ssh client also spawns the same login process. I'll test with my ubuntu docker container tomorrow. Unless there's a different process I'm supposed to spawn in the docker container, I'm not sure if there's anything I can do. Normally the agent can't access the user profile script because it's running as a different user, which is why its supposed to rely on the login process to setup the environment.

vtacquet commented 3 years ago

I can confirm that the Denied is the same for a normal installation (outside of Docker). I do use zsh and Oh-My-Zsh.

image

krayon007 commented 3 years ago

Do you have user consent enabled? The user shell is supposed to spawn a process as the currently logged on user. The denied message looks like a user consent response. If no user is logged in, it should fail with a different error.

krayon007 commented 3 years ago

Does the login shell use colors outside of your docker container?

vtacquet commented 3 years ago

The video is a bit low quality but it is just to show you there is nothing there when using iTerm.

https://user-images.githubusercontent.com/5128967/104121648-2cd37500-5340-11eb-8bfa-7cb0a1bcfebd.mp4

vtacquet commented 3 years ago

Very strange but the Login shell has only partial colours... The motd still shows its colours but the prompt has lost all colours.

image

vtacquet commented 3 years ago

seems that with the Login shell the default TERM=xterm is set instead of TERM=xterm-256color

(the motd doesn't check the TERM settings so that is why it is in colours)

krayon007 commented 3 years ago

seems that with the Login shell the default TERM=xterm is set instead of TERM=xterm-256color

(the motd doesn't check the TERM settings so that is why it is in colours)

Thanks! I'll check to make sure this is set to xterm-256color

krayon007 commented 3 years ago

ok, I did a bunch of testing... It seems with the default TERM=xterm colors seems to work fine with bash, both inside and outside a docker container.

I built a docker image with zsh, and I can't get the terminal to show with colors, even with TERM=xterm-256color

vtacquet commented 3 years ago

try with this Dockerfile, it will install Oh My Zsh (this changes the prompt to colours)

FROM ubuntu:latest

ENV DEBIAN_FRONTEND=noninteractive
ENV TERM=xterm-256color

RUN apt -y update && \
    apt -y install zsh curl git

RUN yes | sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

image

krayon007 commented 3 years ago

ok thanks! I created a new docker image, and verified it works with the change. It will be in the next agent update.

Ylianst commented 3 years ago

MeshCentral v0.7.47 was released with Bryan fix for this. Let us know if it works.

vtacquet commented 3 years ago

Root and Login Shell now have colours, that's perfect but I still get the Denied on the User Shell.

krayon007 commented 3 years ago

Root and Login Shell now have colours, that's perfect but I still get the Denied on the User Shell.

If you are using docker, that is normal. The "user" shell, just spawns a shell with the UID of the logged in user. However, with docker, there is no "logged in user", or at least the agent can't determine the logged in user, because who returns nothing.

vtacquet commented 3 years ago

This is not a docker test, this is just a regular Ubuntu 20.04 LTS (with zsh and Oh My Zsh).

krayon007 commented 3 years ago

This is not a docker test, this is just a regular Ubuntu 20.04 LTS (with zsh and Oh My Zsh).

That's wierd. I just tested on my Ubuntu 20.04 LTS, and it works fine. (granted I'm not using zsh, but I don't think that should be an issue)

If you click on the 'events' tab, does it show anything? If you connect a 'root' terminal, and type who, what does it say? (Is there a user actually logged into this machine?) What does it say if you type users on the console tab?

vtacquet commented 3 years ago

Hmm right, it is not related to zsh, I have it on hosts with bash too...

In the event viewer you see the disconnect immediately (0 seconds) this is a zsh image

this is a bash image

dinger1986 commented 1 year ago

@si458 can close