ssh added but git clone keeps asking for passwd #5226

Closed
opened 2025-11-02 06:18:27 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @daviddoji on GitHub (Apr 12, 2020).

  • Gitea version (or commit ref):
  • Git version:
  • Operating system:
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I'm running gitea from docker in my server. If I use https, everything works fine. I'm getting problems when I try to clone via ssh. I created a repo and added my ssh pub key to my profiles, as described in the documentation.

To avoid typing each time my username and passed, I would like to use ssh-key authentication. When I try it via ssh, I'm prompted for a password, but it is not clear which password is required.

git clone git@git.elnota.space:daviddoji/dummy_repo.git
Clonando en 'dummy_repo'...
git@git.elnota.space's password: 

As mentioned in a previous issue (https://github.com/go-gitea/gitea/issues/9267) I also tried to:

Update the '.ssh/authorized_keys' file with Gitea SSH keys. (Not needed for the built-in SSH server.)
Resynchronize pre-receive, update and post-receive hooks of all repositories.
Add host to config file to use a different port

My config files:
docker-compose.yml

version: "3"
  gitea:
    image: gitea/gitea:latest
    container_name: gitea
    restart: unless-stopped
    networks:
      - backend-gitea
      - web
    volumes:
      - ./gitea/data:/data
    labels:
      - traefik.backend=gitea
      - traefik.frontend.rule=Host:git.elnota.space
      - traefik.docker.network=web
      - traefik.port=3000
      - traefik.enable=true
    depends_on:
      - gitea-db

  gitea-db:
    image: mariadb
    container_name: gitea-db
    restart: unless-stopped
    env_file:
      - .gitea-env
    networks:
      - backend-gitea
    volumes:
      - ./gitea/data/mariadb:/var/lib/mysql

app.ini

PP_NAME = Gitea: Git with a cup of tea
RUN_MODE = prod
RUN_USER = git

[repository]
ROOT = /data/git/repositories

[repository.local]
LOCAL_COPY_PATH = /data/gitea/tmp/local-repo

[repository.upload]
TEMP_PATH = /data/gitea/uploads

[server]
APP_DATA_PATH    = /data/gitea
SSH_DOMAIN       = git.elnota.space
HTTP_PORT        = 3000
ROOT_URL         = https://git.elnota.space/
DISABLE_SSH      = false
SSH_PORT         = 22
LFS_CONTENT_PATH = /data/git/lfs
DOMAIN           = localhost
LFS_START_SERVER = true
LFS_JWT_SECRET   = 9VIAxePnhrmwrSs7LQEQHpVlyGW206VVRtMmLvKA6Cs
OFFLINE_MODE     = false

[database]
PATH     = /data/gitea/gitea.db
DB_TYPE  = sqlite3
HOST     = localhost:3306
NAME     = gitea
USER     = root
PASSWD   =
SSL_MODE = disable

[indexer]
ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve

[session]
PROVIDER_CONFIG = /data/gitea/sessions
PROVIDER        = file

[picture]
AVATAR_UPLOAD_PATH      = /data/gitea/avatars
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = true

[attachment]
PATH = /data/gitea/attachments

[log]
ROOT_PATH = /data/gitea/log
MODE      = file
LEVEL     = Info

[security]
INSTALL_LOCK   = true
SECRET_KEY     = 55hTSyh3fgBIMiU6v7rJXYvlDVacFs8gt5jxV7WLGLe6y234aR1nsKAWSQfEkB2D
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cC54IkpXVCJ9.eyJuYmYiOjE1NDczNzY4Nzd9.kpA6uxCGfbVrX0WEdN48d0-tT3MqStEIHEyneA$

[service]
DISABLE_REGISTRATION              = false
REQUIRE_SIGNIN_VIEW               = false
REGISTER_EMAIL_CONFIRM            = false
ENABLE_NOTIFY_MAIL                = false
ALLOW_ONLY_EXTERNAL_REGISTRATION  = false
ENABLE_CAPTCHA                    = false
DEFAULT_KEEP_EMAIL_PRIVATE        = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING       = true
NO_REPLY_ADDRESS                  = noreply.example.org

[mailer]
ENABLED = false

[openid]
ENABLE_OPENID_SIGNIN = true
ENABLE_OPENID_SIGNUP = true

[oauth2]
JWT_SECRET = 4p9eLLEZWMGLgBt3XZEzO61bCxfEf2SCUj1PpcDW2_s

local .ssh/config

Host git.elnota.space
    Hostname git.elnota.space
    Port 5005
    User git

Screenshots

Originally created by @daviddoji on GitHub (Apr 12, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): - Git version: - Operating system: - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description I'm running gitea from docker in my server. If I use https, everything works fine. I'm getting problems when I try to clone via ssh. I created a repo and added my ssh pub key to my profiles, as described in the documentation. To avoid typing each time my username and passed, I would like to use ssh-key authentication. When I try it via ssh, I'm prompted for a password, but it is not clear which password is required. ``` git clone git@git.elnota.space:daviddoji/dummy_repo.git Clonando en 'dummy_repo'... git@git.elnota.space's password: ``` As mentioned in a previous issue (https://github.com/go-gitea/gitea/issues/9267) I also tried to: Update the '.ssh/authorized_keys' file with Gitea SSH keys. (Not needed for the built-in SSH server.) Resynchronize pre-receive, update and post-receive hooks of all repositories. Add host to config file to use a different port My config files: docker-compose.yml ``` version: "3" gitea: image: gitea/gitea:latest container_name: gitea restart: unless-stopped networks: - backend-gitea - web volumes: - ./gitea/data:/data labels: - traefik.backend=gitea - traefik.frontend.rule=Host:git.elnota.space - traefik.docker.network=web - traefik.port=3000 - traefik.enable=true depends_on: - gitea-db gitea-db: image: mariadb container_name: gitea-db restart: unless-stopped env_file: - .gitea-env networks: - backend-gitea volumes: - ./gitea/data/mariadb:/var/lib/mysql ``` app.ini ``` PP_NAME = Gitea: Git with a cup of tea RUN_MODE = prod RUN_USER = git [repository] ROOT = /data/git/repositories [repository.local] LOCAL_COPY_PATH = /data/gitea/tmp/local-repo [repository.upload] TEMP_PATH = /data/gitea/uploads [server] APP_DATA_PATH = /data/gitea SSH_DOMAIN = git.elnota.space HTTP_PORT = 3000 ROOT_URL = https://git.elnota.space/ DISABLE_SSH = false SSH_PORT = 22 LFS_CONTENT_PATH = /data/git/lfs DOMAIN = localhost LFS_START_SERVER = true LFS_JWT_SECRET = 9VIAxePnhrmwrSs7LQEQHpVlyGW206VVRtMmLvKA6Cs OFFLINE_MODE = false [database] PATH = /data/gitea/gitea.db DB_TYPE = sqlite3 HOST = localhost:3306 NAME = gitea USER = root PASSWD = SSL_MODE = disable [indexer] ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve [session] PROVIDER_CONFIG = /data/gitea/sessions PROVIDER = file [picture] AVATAR_UPLOAD_PATH = /data/gitea/avatars DISABLE_GRAVATAR = false ENABLE_FEDERATED_AVATAR = true [attachment] PATH = /data/gitea/attachments [log] ROOT_PATH = /data/gitea/log MODE = file LEVEL = Info [security] INSTALL_LOCK = true SECRET_KEY = 55hTSyh3fgBIMiU6v7rJXYvlDVacFs8gt5jxV7WLGLe6y234aR1nsKAWSQfEkB2D INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cC54IkpXVCJ9.eyJuYmYiOjE1NDczNzY4Nzd9.kpA6uxCGfbVrX0WEdN48d0-tT3MqStEIHEyneA$ [service] DISABLE_REGISTRATION = false REQUIRE_SIGNIN_VIEW = false REGISTER_EMAIL_CONFIRM = false ENABLE_NOTIFY_MAIL = false ALLOW_ONLY_EXTERNAL_REGISTRATION = false ENABLE_CAPTCHA = false DEFAULT_KEEP_EMAIL_PRIVATE = false DEFAULT_ALLOW_CREATE_ORGANIZATION = true DEFAULT_ENABLE_TIMETRACKING = true NO_REPLY_ADDRESS = noreply.example.org [mailer] ENABLED = false [openid] ENABLE_OPENID_SIGNIN = true ENABLE_OPENID_SIGNUP = true [oauth2] JWT_SECRET = 4p9eLLEZWMGLgBt3XZEzO61bCxfEf2SCUj1PpcDW2_s ``` local .ssh/config ``` Host git.elnota.space Hostname git.elnota.space Port 5005 User git ``` ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the issue/stale label 2025-11-02 06:18:27 -06:00
Author
Owner

@Batuto commented on GitHub (Apr 23, 2020):

Maybe it keeps asking because your connections are going to the SSH (server) of your (host) server or somewhere else and not to the ssh server of gitea docker container.
It seems that you are not mapping the ssh port from the gitea container to the host.
You need to add that in you docker compose file. Also configure the firewall/router properly.

@Batuto commented on GitHub (Apr 23, 2020): Maybe it keeps asking because your connections are going to the SSH (server) of your (host) server or somewhere else and not to the ssh server of gitea docker container. It seems that you are not mapping the ssh port from the gitea container to the host. You need to add that in you docker compose file. Also configure the firewall/router properly.
Author
Owner

@daviddoji commented on GitHub (Apr 25, 2020):

@Batuto I have tried to make it even simpler. Standard ports on server and container and still not able to clone via ssh.
But definitively, the issue you suggest is the culprit of it.

@daviddoji commented on GitHub (Apr 25, 2020): @Batuto I have tried to make it even simpler. Standard ports on server and container and still not able to clone via ssh. But definitively, the issue you suggest is the culprit of it.
Author
Owner

@stale[bot] commented on GitHub (Jun 25, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Jun 25, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@stale[bot] commented on GitHub (Jul 11, 2020):

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale[bot] commented on GitHub (Jul 11, 2020): This issue has been automatically closed because of inactivity. You can re-open it if needed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5226