gitblit-org / gitblit

pure java git solution
http://gitblit.com
Apache License 2.0
2.27k stars 671 forks source link

Cannot add ssh keys to gitblit running in docker container #1415

Open Ivan-Shestakov opened 2 years ago

Ivan-Shestakov commented 2 years ago

Trying to add ssh keys to a user in running gitblit/gitblit:rpc version from docker.io. Nothing happens when I click add button in users profile, ssh keys tab. Viewing network in dev-tools shows the ajax call succeeded (status code 200), but the key isn't added. While troubleshooting, I tried to push the key via command line, but keep getting errors about problems reading ssh keys from stdin

cat id_rsa.pub | ssh -l admin -p 29418 localhost keys add Password authentication Password: The data read from SDTIN can not be parsed as an SSH public key!

podman logs gitblit shows: 2022-05-01 14:38:59 [INFO ] 1 repository models loaded for admin in 1 msecs 2022-05-01 14:38:59 [INFO ] loading ssh keystore for admin 2022-05-02 07:24:34 [INFO ] 1 repository models loaded for admin in 1 msecs 2022-05-02 07:24:34 [INFO ] loading ssh keystore for admin 2022-05-02 07:27:29 [INFO ] creating ssh session from /10.184.0.1:43458 2022-05-02 07:27:31 [INFO ] onExecute: RootDispatcher exits with: 1 2022-05-02 07:27:31 [INFO ] closed ssh session from /10.184.0.1:43458

Docker image version

REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/gitblit/gitblit rpc 90cf9827d633 3 weeks ago 256 MB Host linux version: RHEL 8.5 (hence usage of podman instead of docker)

Steps to reproduce: 1) As a root user, run podman pull gitblit/gitblit:rpc 2) run podman run -d --name gitblit -v gitblit-data:/var/opt/gitblit -p 8443:8443 -p 8080:8080 -p 9418:9418 -p 29418:29418 gitblit/gitblit 3) open web ui on port 8443 and login with default admin/admin user 4) navigate to "my profile" and switch to ssh keys tab. Attempt to paste an ssh public key value and click "add" button Expected - the key is added, and can be used to push content to repositories Actual - nothing happens

flaix commented 2 years ago

I tried with Docker under MacOS and cannot reproduce. Will try again with Podman under Linux, as I assume you are using Linux.

flaix commented 2 years ago

I cannot reproduce this. I followed the steps listed above. Works without a fault, the key is added and can be used to connect to the Gitblit server with SSH.

So in general it is working. The question is what are the special conditions are to make this fail.

I tried this with the docker image as mentioned above. Browser was a Firefox 103, SSH key was 3072bit RSA key.

ssh-keygen -l -f id_rsa_gbtest
3072 SHA256:OkVZBmvZN3gI0Mg8JUQVJL9rFTIi737fTeS96ysc0RA florian@mints (RSA)

The error mentioned above seems to indicate that the file pasted was not a recognisable public key, although the name suggests that it is an RSA key.

flaix commented 1 year ago

Maybe the Gitblit process has no write access to the directory data/ssh where it would store the keys?

flaix commented 1 year ago

The WebUI now got feedback (in commit 2f122c9657aa22216d0a4d6e438bc60f9d9b6e22) when the key could not be parsed. Maybe this helps to identify the problem. This will be available in the next nighty build of the Gitblit docker container.