-
Notifications
You must be signed in to change notification settings - Fork 6k
[Bug]: When I run code-server with sudo, it said incorrect password. #6380
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
Comments
Which config.yaml? If you are using sudo then the home directory
will be /root, so the config file will be in
/root/.config/code-server/config.yaml.
It is not recommended to run code-server as root though.
|
But there isn't the config file in /root/.config/code-server/config.yaml |
Strange, there should be. code-server will create the config file
if it does not exist. Here is a test I did:
```
$ sudo file /root/.config/config.yaml
/root/.config/code-server/config.yaml: cannot open `/root/.config/code-server/config.yaml' (No such file or directory)
$ sudo code-server
[2023-08-10T19:32:01.104Z] info Wrote default config file to ~/.config/code-server/config.yaml
[2023-08-10T19:32:01.407Z] info code-server 4.16.1 94ef377
[2023-08-10T19:32:01.408Z] info Using user-data-dir ~/.local/share/code-server
[2023-08-10T19:32:01.420Z] info Using config file ~/.config/code-server/config.yaml
[2023-08-10T19:32:01.420Z] info HTTP server listening on http://127.0.0.1:8080/
[2023-08-10T19:32:01.420Z] info - Authentication is enabled
[2023-08-10T19:32:01.420Z] info - Using password from ~/.config/code-server/config.yaml
[2023-08-10T19:32:01.420Z] info - Not serving HTTPS
[2023-08-10T19:32:01.420Z] info Session server listening on /root/.local/share/code-server/code-server-ipc.sock
^C
$ sudo file /root/.config/config.yaml
/root/.config/code-server/config.yaml: ASCII text
```
Something you can try is to run `sudo code-server --verbose`. It
will show you the full paths being used. For example:
```
$ sudo code-server --verbose
[2023-08-10T19:37:51.870Z] debug child:8357 got message {"message":{"type":"handshake","args":{"bind-addr":"127.0.0.1:8080","auth":"password","password":"<redacted>","config":"/root/.config/code-server/config.yaml","verbose":true,"user-data-dir":"/root/.local/share/code-server","extensions-dir":"/root/.local/share/code-server/extensions","session-socket":"/root/.local/share/code-server/code-server-ipc.sock","log":"trace","host":"127.0.0.1","port":8080,"proxy-domain":[],"_":[],"usingEnvPassword":false,"usingEnvHashedPassword":false}}}
```
Here you can see the config is
`/root/.config/code-server/config.yaml`.
|
I made a change that outputs the full path so if you are still running into this please upgrade and try again. Please feel free to comment and we can re-open if there is still a bug. |
Hello this exact same issue is happening to me. Though, one thing to note is I'm using docker image to run code-server. Below is the output when I run docker command - as provided by the website. But no such config file can be found! Where is it writing default config file to in case of docker + sudo?
|
It should be in |
Yes! It does inside the container. Thank you for pointing that out. |
Is there an existing issue for this?
OS/Web Information
Web Browser: Chrome
Local OS: Windows 10
Remote OS: Ubuntu 20.04
Remote Architecture:
code-server --version: 4.10.1
Steps to Reproduce
run
sudo code-server --port 8080 --host 0.0.0.0 --auth password
login page
enter password on config.yaml file and show Incorrect password
Expected
Login successfully
Actual
Incorrect password
Logs
[2023-08-09T13:33:23.584Z] info code-server 4.10.1 d477972
[2023-08-09T13:33:23.586Z] info Using user-data-dir ~/.local/share/code-server
[2023-08-09T13:33:23.614Z] info Using config file ~/.config/code-server/config.yaml
[2023-08-09T13:33:23.614Z] info HTTP server listening on http://0.0.0.0:8080/
[2023-08-09T13:33:23.614Z] info - Authentication is enabled
[2023-08-09T13:33:23.614Z] info - Using password from ~/.config/code-server/config.yaml
[2023-08-09T13:33:23.614Z] info - Not serving HTTPS
Failed login attempt {"remoteAddress":"10.9.64.80","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36","timestamp":1691588009}
Screenshot/Video
No response
Does this issue happen in VS Code or GitHub Codespaces?
Are you accessing code-server over HTTPS?
Notes
When I run code-server with sudo, I encountered the issue (incorrect password). However, it worked without sudo.
The text was updated successfully, but these errors were encountered: