-
You are missing the onedev ssh port in the url. Try below instead:
git clone ssh://code.onedev.io:6611/onedev/server -
@robin - you can see in the response back that the correct port has been used as per what was configured in the SSH config file.
-
I see you are cloning using below command:
git clone ssh://onedevio/onedev/serverI can clone with below command successfully:
git clone ssh://code.onedev.io:6611/onedev/serverIf still not working, please let me know exact command used to generate your SSH keys
-
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/rhdev/.ssh/id_rsa): onedeviokey Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in onedeviokey Your public key has been saved in onedeviokey.pub The key fingerprint is: SHA256:...snip... rhdev@laptop The key's randomart image is: +---[RSA 3072]----+ ... snip ... +----[SHA256]-----+SSH config:
Host code.onedev.io HostName code.onedev.io Port 6611 User rhdev IdentityFile ~/.ssh/onedeviokey$ git clone ssh://code.onedev.io:6611/onedev/server Cloning into 'server'... [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. -
Not sure why this is happening. I am testing on Mac and it works fine. What is your OS? Are your public key starts with ssh_rsa?
-
@robin Yep. Started with SSH-RSA. I tried again using verbose output:
$ git clone --verbose --progress ssh://code.onedev.io:6611/onedev/server -c core.sshCommand="ssh -v" Cloning into 'server'... OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021 debug1: Reading configuration data /home/rhdev/.ssh/config debug1: /home/rhdev/.ssh/config line 66: Applying options for code.onedev.io debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to code.onedev.io [52.35.0.81] port 6611. debug1: Connection established. debug1: identity file /home/rhdev/.ssh/onedeviokey type 0 debug1: identity file /home/rhdev/.ssh/onedeviokey-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.8 debug1: Remote protocol version 2.0, remote software version APACHE-SSHD-2.7.0 debug1: compat_banner: no match: APACHE-SSHD-2.7.0 debug1: Authenticating to code.onedev.io:6611 as 'rhdev' debug1: load_hostkeys: fopen /home/rhdev/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: ecdh-sha2-nistp256 debug1: kex: host key algorithm: rsa-sha2-512 debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: SSH2_MSG_KEX_ECDH_REPLY received debug1: Server host key: ssh-rsa SHA256:Gg0OiQ2xJfb8FZ5KP7X697F0UXtaWyPg0IlZJkwTt2o debug1: load_hostkeys: fopen /home/rhdev/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: Host '[code.onedev.io]:6611' is known and matches the RSA host key. debug1: Found key in /home/rhdev/.ssh/known_hosts:104 debug1: rekey out after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey in after 4294967296 blocks debug1: Will attempt key: /home/rhdev/.ssh/onedeviokey RSA SHA256:...snip... explicit debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering public key: /home/rhdev/.ssh/onedeviokey RSA SHA256:...snip... explicit debug1: send_pubkey_test: no mutual signature algorithm debug1: No more authentication methods to try. [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.This gave me a clue - I believe it's not supporting RSA? I recreated using ed25519 algo instead:
$ssh-keygen -t ed25519 -C "[email protected]"I can now clone the server repo:
$ git clone --verbose --progress ssh://codeonedevio2:6611/onedev/server -c core.sshCommand="ssh -v" Cloning into 'server'... OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021 debug1: Reading configuration data /home/rhdev/.ssh/config debug1: /home/rhdev/.ssh/config line 72: Applying options for codeonedevio2 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to code.onedev.io [52.35.0.81] port 6611. debug1: Connection established. debug1: identity file /home/rhdev/.ssh/onedeviokey2 type 3 debug1: identity file /home/rhdev/.ssh/onedeviokey2-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.8 debug1: Remote protocol version 2.0, remote software version APACHE-SSHD-2.7.0 debug1: compat_banner: no match: APACHE-SSHD-2.7.0 debug1: Authenticating to code.onedev.io:6611 as 'rhdev' debug1: load_hostkeys: fopen /home/rhdev/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: ecdh-sha2-nistp256 debug1: kex: host key algorithm: rsa-sha2-512 debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: SSH2_MSG_KEX_ECDH_REPLY received debug1: Server host key: ssh-rsa SHA256:Gg0OiQ2xJfb8FZ5KP7X697F0UXtaWyPg0IlZJkwTt2o debug1: load_hostkeys: fopen /home/rhdev/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: Host '[code.onedev.io]:6611' is known and matches the RSA host key. debug1: Found key in /home/rhdev/.ssh/known_hosts:104 debug1: rekey out after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey in after 4294967296 blocks debug1: Will attempt key: /home/rhdev/.ssh/onedeviokey2 ED25519 SHA256:...snip... explicit debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering public key: /home/rhdev/.ssh/onedeviokey2 ED25519 SHA256:...snip...o explicit debug1: Server accepts key: /home/rhdev/.ssh/onedeviokey2 ED25519 SHA256:...snip... explicit Authenticated to code.onedev.io ([52.35.0.81]:6611) using "publickey". debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: pledge: filesystem full debug1: Sending environment. debug1: channel 0: setting env GIT_PROTOCOL = "version=2" debug1: Sending command: git-upload-pack '/onedev/server' remote: Enumerating objects: 176231, done. remote: Counting objects: 100% (9409/9409), done. remote: Compressing objects: 100% (5613/5613), done. remote: Total 176231 (delta 5047), reused 4226 (delta 2366), pack-reused 166822 Receiving objects: 100% (176231/176231), 168.28 MiB | 387.00 KiB/s, done. Resolving deltas: 100% (107531/107531), done. debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 Transferred: sent 37568, received 176878916 bytes, in 448.8 seconds Bytes per second: sent 83.7, received 394120.7 debug1: Exit status 0 -
This is odd. Both rsa and ed25519 key works at my side. What is your OS/version?
-
Also please check if this helps:
-
Are you able to use your RSA keys to clone via SSH over github?
-
OneDev
changed state to 'Closed' 4 years ago
Previous Value Current Value Open
Closed
-
OneDev
changed state to 'Released' 4 years ago
Previous Value Current Value Closed
Released
-
State changed as build #2259 is successful
-
@rhdev, try to do this command to apply your generated key go git config, and it will work like a charm.
git config --add --local core.sshCommand 'ssh -i <path_to_your_private_key>' -
Same problem here with OneDev 8.5.0. I can't use SSH to clone a repository from a local OneDev instance, using my SSH private key. I even tried generating / importing an ed25519 key, and it still fails.
I really want to use self-hosted OneDev, but if I can't even get SSH working, it's a deal breaker. Thanks for the free software though .... it's pretty cool.
-
Can you please let me know the detailed reproducing steps? This always works at my side (and on many others using OneDev).
-
I just set up a new Docker container with OneDev, and it's working fine now. I have no idea what was going on before. It was weird.
-
I’m experiencing the same issue. On my server, I have a reverse proxy mapping from port 2222 to 6611. The connection is established, but I get an “authentication failed” error.
My steps:
$ssh-keygen -t ed25519 -C "[email protected]"- Add public key on SSH Keys under OneDev profile
- Renamed keys to
one-devand stored them under~/.ssh/one-dev/ - Set config to:
Host one-dev HostName URL User git Port 2222 IdentityFile ~/.ssh/one-dev/one-dev- ssh -vvv one-dev:
$ ssh -vvv one-dev debug1: OpenSSH_10.0p2, OpenSSL 3.5.3 16 Sep 2025 debug3: Running on MINGW64_NT-10.0-26200 3.6.4-b9f03e96.x86_64 2025-07-16 18:17 UTC x86_64 debug3: Started with: ssh -vvv one-dev debug1: Reading configuration data /c/Users/USER/.ssh/config debug1: /c/Users/USER/.ssh/config line 43: Applying options for one-dev debug1: Reading configuration data /etc/ssh/ssh_config debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/c/Users/USER/.ssh/known_hosts' debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/c/Users/USER/.ssh/known_hosts2' debug2: resolving "URL" port 2222 debug3: resolve_host: lookup URL:2222 debug3: channel_clear_timeouts: clearing debug3: ssh_connect_direct: entering debug1: Connecting to URL [IP_ADDRESS] port 2222. debug3: set_sock_tos: set socket 4 IP_TOS 0x48 debug1: Connection established. debug1: identity file /c/Users/USER/.ssh/one-dev/one-dev type 3 debug1: identity file /c/Users/USER/.ssh/one-dev/one-dev-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_10.0 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 4 setting O_NONBLOCK debug1: Authenticating to URL:2222 as 'git' debug3: put_host_port: [URL]:2222 debug3: record_hostkey: found key type ED25519 in file /c/Users/USER/.ssh/known_hosts:1 debug3: load_hostkeys_file: loaded 1 keys from [URL]:2222 debug1: load_hostkeys: fopen /c/Users/USER/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/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: mlkem768x25519-sha256,sntrup761x25519-sha512,[email protected],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],[email protected],[email protected],aes128-ctr,aes192-ctr,aes256-ctr debug2: ciphers stoc: [email protected],[email protected],[email protected],aes128-ctr,aes192-ctr,aes256-ctr 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: mlkem768x25519-sha256,mlkem768nistp256-sha256,mlkem1024nistp384-sha384,curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,ext-info-s,[email protected] debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 debug2: ciphers ctos: [email protected],[email protected],aes256-ctr,[email protected],aes128-ctr debug2: ciphers stoc: [email protected],[email protected],aes256-ctr,[email protected],aes128-ctr debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512 debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512 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: mlkem768x25519-sha256 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:9SqUViK...KEY debug3: put_host_port: [IP_ADDRESS]:2222 debug3: put_host_port: [URL]:2222 debug3: record_hostkey: found key type ED25519 in file /c/Users/USER/.ssh/known_hosts:1 debug3: load_hostkeys_file: loaded 1 keys from [URL]:2222 debug1: load_hostkeys: fopen /c/Users/USER/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: Host '[URL]:2222' is known and matches the ED25519 host key. debug1: Found key in /c/Users/USER/.ssh/known_hosts:1 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: mlkem768x25519-sha256,sntrup761x25519-sha512,[email protected],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],[email protected],[email protected],aes128-ctr,aes192-ctr,aes256-ctr debug2: ciphers stoc: [email protected],[email protected],[email protected],aes128-ctr,aes192-ctr,aes256-ctr 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=<ecdsa-sha2-nistp256,[email protected],ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,[email protected],rsa-sha2-256,rsa-sha2-512> 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=<ecdsa-sha2-nistp256,[email protected],ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,[email protected],rsa-sha2-256,rsa-sha2-512> debug3: receive packet: type 51 debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password 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 debug1: Will attempt key: /c/Users/USER/.ssh/one-dev/one-dev ED25519 SHA256:qd+nj...KEY explicit debug2: pubkey_prepare: done debug1: Offering public key: /c/Users/USER/.ssh/one-dev/one-dev ED25519 SHA256:qd+nj...KEY explicit 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,gssapi-keyex,gssapi-with-mic,password debug2: we did not send a packet, disable method debug3: authmethod_lookup password debug3: remaining preferred: ,password debug3: authmethod_is_enabled password debug1: Next authentication method: password git@URL's password:- or
$ git clone one-dev:to/path Cloning into 'path'... git@URL's password: Permission denied, please try again. git@URL's password: fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.I use Windows 11 and on my server Rocky Linux v10.2 is running which is behind a Traefik reverse proxy.
-
It works now, one port was wrong in the port mapping of the reverse proxy Traefik. :)
And take a attention that the path must begin with
/. So instead ofgit clone one-dev:to/path, it must begit clone one-dev:/to/path.
| Type |
Bug
|
| Priority |
Normal
|
| Assignee | |
| Affected Versions |
Not Found
|
Same problem as issue onedev/server#512.
SSH config file created as follows: