Skip to content
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

Cloning via ssh asks for password #9267

Closed
2 of 7 tasks
derkaan opened this issue Dec 6, 2019 · 2 comments
Closed
2 of 7 tasks

Cloning via ssh asks for password #9267

derkaan opened this issue Dec 6, 2019 · 2 comments
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.

Comments

@derkaan
Copy link

derkaan commented 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
@lunny lunny added the type/question Issue needs no code to be fixed, only a description on how to fix it yourself. label Dec 6, 2019
@lunny
Copy link
Member

lunny commented Dec 6, 2019

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

@derkaan
Copy link
Author

derkaan commented 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

@zeripath zeripath closed this as completed Dec 8, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.
Projects
None yet
Development

No branches or pull requests

3 participants