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

Problems with multiple ssh keys #33762

Open
CapSel opened this issue Mar 1, 2025 · 9 comments
Open

Problems with multiple ssh keys #33762

CapSel opened this issue Mar 1, 2025 · 9 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/bug

Comments

@CapSel
Copy link

CapSel commented Mar 1, 2025

Description

I can't pull from gitea. The error is:

git@domain: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

But this is not same problem as in FAQ.

I've got 2 ssh public keys for 2 computers for single user. Only second key works, first one gives me the error.

Of course I tried removing and adding this currently-not-working key again, I verified it. Then it works but the other key stops - same symptoms.

I deployed gitea with docker image "gitea/gitea". Entire configuration was done by Web UI.

Logs from gitea when there is a failure:

Connection closed by authenticating user git IP.IP.IP.IP port 58344 [preauth]

Repo has remote set with url ssh://git@domain:917/UserName/repo.git for fetch and push. As mentioned before - it works only with "last" key.

Gitea Version

1.23.4

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

Archlinux/docker

How are you running Gitea?

docker-compose part for gitea:

  gitea:
    image: gitea/gitea
    container_name: gitea
    restart: always
    depends_on:
      - db
    env_file:
      - ./gitea.env
    volumes:
      - /srv/gitea/data:/srv/git
      - /srv/gitea/config:/data/gitea/conf
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    ports:
      - "127.0.0.1:3001:3000"
      - "917:22"

Frontend for Web UI is nginx outside of docker.

Database

PostgreSQL

@CapSel CapSel added the type/bug label Mar 1, 2025
@lunny
Copy link
Member

lunny commented Mar 2, 2025

Can you run git -vvv to find the permission deny reason?

@lunny lunny added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Mar 2, 2025
@CapSel
Copy link
Author

CapSel commented Mar 2, 2025

Unfortunately git pull --rebase -vvv shows nothing more then my initial report - no new lines, timestamps, characters. The output is exactly the same.
I tried adding more v and nothing changes.

@CapSel
Copy link
Author

CapSel commented Mar 2, 2025

Running "Update the '.ssh/authorized_keys' file with Gitea SSH keys." Caused keys to be switched again.

@lunny
Copy link
Member

lunny commented Mar 2, 2025

Unfortunately git pull --rebase -vvv shows nothing more then my initial report - no new lines, timestamps, characters. The output is exactly the same. I tried adding more v and nothing changes.

Sorry, it should be ssh -vvv. Please search how to use that.

@tuxdotrs
Copy link

tuxdotrs commented Mar 3, 2025

Facing the same issue (v1.23.4). Here's the output for ssh -vvv [email protected]

OpenSSH_9.9p2, OpenSSL 3.4.1 11 Feb 2025
debug1: Reading configuration data /home/tux/.ssh/config
debug1: /home/tux/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config line 2: Including file /nix/store/cl6fadhi66qch2nc0zmzyvxmlylp35ca-libvirt-10.10.0/etc/ssh/ssh_config.d/30-libvirt-ssh-proxy.conf depth 0
debug1: Reading configuration data /nix/store/cl6fadhi66qch2nc0zmzyvxmlylp35ca-libvirt-10.10.0/etc/ssh/ssh_config.d/30-libvirt-ssh-proxy.conf
debug1: /etc/ssh/ssh_config line 6: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/tux/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/tux/.ssh/known_hosts2'
debug2: resolving "git.tux.rs" port 22
debug3: resolve_host: lookup git.tux.rs:22
debug3: channel_clear_timeouts: clearing
debug3: ssh_connect_direct: entering
debug1: Connecting to git.tux.rs [156.67.105.203] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: Connection established.
debug1: identity file /home/tux/.ssh/id_ed25519 type 3
debug1: identity file /home/tux/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_9.9
debug1: compat_banner: match: OpenSSH_9.9 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to git.tux.rs:22 as 'gitea'
debug3: record_hostkey: found key type ED25519 in file /home/tux/.ssh/known_hosts:15
debug3: load_hostkeys_file: loaded 1 keys from git.tux.rs
debug1: load_hostkeys: fopen /home/tux/.ssh/known_hosts2: No such file or directory
debug3: order_hostkeyalgs: have matching best-preference key type [email protected], using HostkeyAlgorithms verbatim
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: sntrup761x25519-sha512,[email protected],mlkem768x25519-sha256,curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c,[email protected]
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,[email protected],diffie-hellman-group-exchange-sha256,mlkem768x25519-sha256,sntrup761x25519-sha512,ext-info-s,[email protected]
debug2: host key algorithms: ssh-ed25519
debug2: ciphers ctos: [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
debug2: ciphers stoc: [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
debug2: MACs ctos: [email protected],[email protected],[email protected]
debug2: MACs stoc: [email protected],[email protected],[email protected]
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug3: kex_choose_conf: will use strict KEX ordering
debug1: kex: algorithm: sntrup761x25519-sha512
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:UYz7tTRfgTugkcPwZnKvcl4aRSoUWU2CbJiEPis1Qno
debug3: record_hostkey: found key type ED25519 in file /home/tux/.ssh/known_hosts:15
debug3: load_hostkeys_file: loaded 1 keys from git.tux.rs
debug1: load_hostkeys: fopen /home/tux/.ssh/known_hosts2: No such file or directory
debug1: Host 'git.tux.rs' is known and matches the ED25519 host key.
debug1: Found key in /home/tux/.ssh/known_hosts:15
debug3: send packet: type 21
debug1: ssh_packet_send2_wrapped: resetting send seqnr 3
debug2: ssh_set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: Sending SSH2_MSG_EXT_INFO
debug3: send packet: type 7
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: ssh_packet_read_poll2: resetting read seqnr 3
debug1: SSH2_MSG_NEWKEYS received
debug2: ssh_set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug2: KEX algorithms: sntrup761x25519-sha512,[email protected],mlkem768x25519-sha256,curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c,[email protected]
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug3: kex_input_ext_info: extension server-sig-algs
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256>
debug3: kex_input_ext_info: extension [email protected]
debug1: kex_ext_info_check_ver: [email protected]=<0>
debug3: kex_input_ext_info: extension [email protected]
debug1: kex_ext_info_check_ver: [email protected]=<0>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug3: kex_input_ext_info: extension server-sig-algs
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256>
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug3: ssh_get_authentication_socket_path: path '/run/user/1000/wezterm/agent.1407668'
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: agent returned 1 keys
debug1: Will attempt key: /home/tux/.ssh/id_ed25519 ED25519 SHA256:pWSDrOnWU3NfQi326Ww30rGq7ddUzmc3swfqmQe8gYo explicit agent
debug2: pubkey_prepare: done
debug1: Offering public key: /home/tux/.ssh/id_ed25519 ED25519 SHA256:pWSDrOnWU3NfQi326Ww30rGq7ddUzmc3swfqmQe8gYo explicit agent
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

@CapSel
Copy link
Author

CapSel commented Mar 4, 2025

The issue solved itself for me. My initial assumption that running "Update the '.ssh/authorized_keys' file with Gitea SSH keys." switched keys was wrong.

@lunny
Copy link
Member

lunny commented Mar 4, 2025

The issue solved itself for me. My initial assumption that running "Update the '.ssh/authorized_keys' file with Gitea SSH keys." switched keys was wrong.

How did you resolve the problem? Is this a bug of Gitea or could you share your workaround?

@CapSel
Copy link
Author

CapSel commented Mar 4, 2025

My workaround was to go to "Site Administration" and click "Run" next to "Update the '.ssh/authorized_keys' file with Gitea SSH keys.".

I'm afraid that adding third key would break things for me again.

@tuxdotrs
Copy link

tuxdotrs commented Mar 4, 2025

My workaround was to go to "Site Administration" and click "Run" next to "Update the '.ssh/authorized_keys' file with Gitea SSH keys.".

I'm afraid that adding third key would break things for me again.

tried this and it doesn't work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/bug
Projects
None yet
Development

No branches or pull requests

3 participants