Cloning via ssh asks for password #4450

Closed
opened 2025-11-02 05:51:12 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @derkaan on GitHub (Dec 6, 2019).

  • Gitea version (or commit ref): Gitea version 1.11.0+dev-379-gd67220680 built with GNU Make 4.2.1, go1.13.5 : bindata, sqlite, sqlite_unlock_notify
  • Git version: git version 2.22.0
  • Operating system: Host=OSX, Gitea=official docker image
  • 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 installed Gitea as described on in the documentation and except cloning via ssh works.
After installation I created a repo and also added my ssh pub key to my profile.

cloning via http works fine

git clone http://gitea.test:4000/my-user/test-repo.git
Cloning into 'testrepo'...
Username for 'http://gitea.test:4000': my-user
Password for 'http://my-user@gitea.test:4000':  ****
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.

This is ok, but I would like to use ssh-key authentication to avoid entering my credentials everytime. When I try it via ssh, I'm prompted for a password, but it is not clear which password is required.

git clone git@gitea.test:2222:my-user/test-repo.git                                                                                                             
Cloning into 'test-repo'...
Password:

As mentioned in several issue entries 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.

but again without luck.

Any suggestion, how on how to setup cloning via ssh?

These are the config settings I use:

docker-compose.yml

version: "2"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:latest 
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=db:3306
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      - ./data:/data
    ports:
       - "4000:3000"
       - "2222:22"
    depends_on:
      - db

  db:
    image: mariadb:10
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
      - ./mysql:/var/lib/mysql

app.ini

APP_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       = gitea.test:2222
HTTP_PORT        = 3000
ROOT_URL         = http://gitea.test:4000/
DISABLE_SSH      = false
SSH_PORT         = 22
SSH_LISTEN_PORT  = 22
LFS_START_SERVER = true
LFS_CONTENT_PATH = /data/git/lfs
DOMAIN           = gitea.test:3000
LFS_JWT_SECRET   = RCppBOWt2FZ0f9eN8a4UrJN3qKex3Z4tX4m-seTTpwI
OFFLINE_MODE     = false
START_SSH_SERVER = true

[database]
PATH     = /data/gitea/gitea.db
DB_TYPE  = mysql
HOST     = db:3306
NAME     = gitea
USER     = gitea
PASSWD   = gitea
SSL_MODE = disable
CHARSET  = utf8

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

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

[picture]
AVATAR_UPLOAD_PATH            = /data/gitea/avatars
REPOSITORY_AVATAR_UPLOAD_PATH = /data/gitea/repo-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     = Evia6zSst4hYAo8o5s666nAbdxyFX6P7E2fbHNg5jriRMlA4FVsm6j9CSy7w5T37
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1NzU2MTY4NTB9.LICp9GeGnq97St6BtdITZzPUo2LzCg7fgQPjwA0nHOM

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

[oauth2]
JWT_SECRET = 8qlr2-xZUihdBO6SJJ9BgEiDKLFU-0SRvsbw55xDANg

[mailer]
ENABLED = false

[openid]
ENABLE_OPENID_SIGNIN = true
ENABLE_OPENID_SIGNUP = true

Originally created by @derkaan on GitHub (Dec 6, 2019). <!-- 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): Gitea version 1.11.0+dev-379-gd67220680 built with GNU Make 4.2.1, go1.13.5 : bindata, sqlite, sqlite_unlock_notify - Git version: git version 2.22.0 - Operating system: Host=OSX, Gitea=official docker image - 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 installed Gitea as described on in the documentation and except cloning via ssh works. After installation I created a repo and also added my ssh pub key to my profile. cloning via http works fine ``` bash git clone http://gitea.test:4000/my-user/test-repo.git Cloning into 'testrepo'... Username for 'http://gitea.test:4000': my-user Password for 'http://my-user@gitea.test:4000': **** remote: Enumerating objects: 5, done. remote: Counting objects: 100% (5/5), done. remote: Compressing objects: 100% (4/4), done. remote: Total 5 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (5/5), done. ``` This is ok, but I would like to use ssh-key authentication to avoid entering my credentials everytime. When I try it via ssh, I'm prompted for a password, but it is not clear which password is required. ```bash git clone git@gitea.test:2222:my-user/test-repo.git Cloning into 'test-repo'... Password: ``` As mentioned in several issue entries 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. but again without luck. Any suggestion, how on how to setup cloning via ssh? These are the config settings I use: docker-compose.yml ```yaml version: "2" networks: gitea: external: false services: server: image: gitea/gitea:latest environment: - USER_UID=1000 - USER_GID=1000 - DB_TYPE=mysql - DB_HOST=db:3306 - DB_NAME=gitea - DB_USER=gitea - DB_PASSWD=gitea restart: always networks: - gitea volumes: - ./data:/data ports: - "4000:3000" - "2222:22" depends_on: - db db: image: mariadb:10 restart: always environment: - MYSQL_ROOT_PASSWORD=gitea - MYSQL_USER=gitea - MYSQL_PASSWORD=gitea - MYSQL_DATABASE=gitea networks: - gitea volumes: - ./mysql:/var/lib/mysql ``` app.ini ```ini APP_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 = gitea.test:2222 HTTP_PORT = 3000 ROOT_URL = http://gitea.test:4000/ DISABLE_SSH = false SSH_PORT = 22 SSH_LISTEN_PORT = 22 LFS_START_SERVER = true LFS_CONTENT_PATH = /data/git/lfs DOMAIN = gitea.test:3000 LFS_JWT_SECRET = RCppBOWt2FZ0f9eN8a4UrJN3qKex3Z4tX4m-seTTpwI OFFLINE_MODE = false START_SSH_SERVER = true [database] PATH = /data/gitea/gitea.db DB_TYPE = mysql HOST = db:3306 NAME = gitea USER = gitea PASSWD = gitea SSL_MODE = disable CHARSET = utf8 [indexer] ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve [session] PROVIDER_CONFIG = /data/gitea/sessions PROVIDER = file [picture] AVATAR_UPLOAD_PATH = /data/gitea/avatars REPOSITORY_AVATAR_UPLOAD_PATH = /data/gitea/repo-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 = Evia6zSst4hYAo8o5s666nAbdxyFX6P7E2fbHNg5jriRMlA4FVsm6j9CSy7w5T37 INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1NzU2MTY4NTB9.LICp9GeGnq97St6BtdITZzPUo2LzCg7fgQPjwA0nHOM [service] DISABLE_REGISTRATION = false REQUIRE_SIGNIN_VIEW = true REGISTER_EMAIL_CONFIRM = false ENABLE_NOTIFY_MAIL = false ALLOW_ONLY_EXTERNAL_REGISTRATION = false ENABLE_CAPTCHA = false DEFAULT_KEEP_EMAIL_PRIVATE = true DEFAULT_ALLOW_CREATE_ORGANIZATION = true DEFAULT_ENABLE_TIMETRACKING = true NO_REPLY_ADDRESS = noreply.example.org [oauth2] JWT_SECRET = 8qlr2-xZUihdBO6SJJ9BgEiDKLFU-0SRvsbw55xDANg [mailer] ENABLED = false [openid] ENABLE_OPENID_SIGNIN = true ENABLE_OPENID_SIGNUP = true ```
GiteaMirror added the type/question label 2025-11-02 05:51:12 -06:00
Author
Owner

@lunny commented on GitHub (Dec 6, 2019):

The address is not right.
git clone git@gitea.test:2222:my-user/test-repo.git.

@lunny commented on GitHub (Dec 6, 2019): The address is not right. `git clone git@gitea.test:2222:my-user/test-repo.git`.
Author
Owner

@derkaan commented on GitHub (Dec 6, 2019):

Thanks for the hint. I was able to fix it now.
Let me summarize it here. Just in case somebody in future has the same isse.

The address needs to be adjusted in one of these two ways.
change gitea.test to your actual domain

Option 1:
Conver your adress to use the ssh-format:

git clone ssh://git@gitea.test:2222/my-user/testr-epo.git

Option 2:
in app.ini leave out the port for the ssh domain setting.
This ensures that you get the "correct" address offered for copy & paste

[server]
SSH_DOMAIN       = gitea.test

Set the according details in your .ssh/config.
Portnumber needs to match your exposed port setting for docker.
In my case it is 2222

Host gitea.test
	Port 2222

Then you can clone via

git clone git@gitea.test:my-user/test-repo.git
@derkaan commented on GitHub (Dec 6, 2019): Thanks for the hint. I was able to fix it now. Let me summarize it here. Just in case somebody in future has the same isse. The address needs to be adjusted in one of these two ways. _change gitea.test to your actual domain_ **Option 1:** Conver your adress to use the ssh-format: ```bash git clone ssh://git@gitea.test:2222/my-user/testr-epo.git ``` **Option 2:** in app.ini leave out the port for the ssh domain setting. This ensures that you get the "correct" address offered for copy & paste ```ini [server] SSH_DOMAIN = gitea.test ``` Set the according details in your .ssh/config. Portnumber needs to match your exposed port setting for docker. In my case it is 2222 ```conf Host gitea.test Port 2222 ``` Then you can clone via ```bash git clone git@gitea.test:my-user/test-repo.git ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4450