Password is required to clone repository using ssh

I’m using gitea in a docker environment. The gitea used is a rootless type image.

The http/https port mapping is “8084:3000” and the ssh port mapping is “2224:2222”.

I generated the ssh keys on my Linux host and added them to Gitea.

1- First test:

ssh -p 2224 git@localhost

Message displayed:

PTY allocation request failed on channel 0
Hi there, campos! You’ve successfully authenticated with the key named cacampos@gmail.com, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.
Connection to localhost closed.

2- Second test:

git clone git@localhost:2224/campos/test10.git
Cloning into ‘test10’…
git@localhost’s password:

the format that git expects is ssh://git@localhost:2224/campos/test10.git you can force this format using the USE_COMPAT_SSH_URI setting (docs can be found here: Config Cheat Sheet - Docs)

I edited the /home/campos/.ssh/config file and added the following instructions:

Host localhost
  HostName localhost
  User git
  Port 2224
 IdentityFile ~/.ssh/id_rsa

Then I changed the command url from git clone git@localhost:2224/campos/test10.git to git clone git@localhost:/campos/test10.git. This worked perfectly! I managed to clone the repository.

But as techknowlogick said, the correct thing to do is:

ssh://git@localhost:2224/campos/test10.git

This way it is not necessary to use the config file in ssh.

A question I still have is whether it is possible to hide the port in the url.

If you’re not running a local sshd, you might be able to map port 22 to port 2222, and then you wouldn’t need to specify a port number.

Otherwise, if you already have a standard sshd running at port 22 and can’t co-opt the default port, I’m not sure there’s any way to avoid having the service’s port number in the URL.