Gitea: Cloning via ssh asks for password

Created on 6 Dec 2019  路  2Comments  路  Source: go-gitea/gitea

  • 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

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://[email protected]: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 [email protected]: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

kinquestion

Most helpful comment

The address is not right.
git clone [email protected]:2222:my-user/test-repo.git.

All 2 comments

The address is not right.
git clone [email protected]:2222:my-user/test-repo.git.

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://[email protected]: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 [email protected]:my-user/test-repo.git
Was this page helpful?
0 / 5 - 0 ratings

Related issues

thehowl picture thehowl  路  3Comments

Fastidious picture Fastidious  路  3Comments

kifirkin picture kifirkin  路  3Comments

tuxfanou picture tuxfanou  路  3Comments

thehowl picture thehowl  路  3Comments