# Password is required to clone repository using ssh

**URL:** <https://forum.gitea.com/t/password-is-required-to-clone-repository-using-ssh/5006>\
**Category:** Install/Maintain/Configure\
**Created:** [April 8, 2022, 7:12pm UTC](https://forum.gitea.com/t/password-is-required-to-clone-repository-using-ssh/5006 "2022-04-08T19:12:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![campos](https://avatars.discourse-cdn.com/v4/letter/c/7bcc69/32.png) [@campos](https://forum.gitea.com/u/campos)\
**Post date:** [April 8, 2022, 7:12pm UTC](https://forum.gitea.com/t/password-is-required-to-clone-repository-using-ssh/5006/1 "2022-04-08T19:12:00Z")

</div>

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](mailto: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:

---

<div class="post-metadata">

**Author:** ![techknowlogick](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/techknowlogick/32/4706_2.png) [@techknowlogick](https://forum.gitea.com/u/techknowlogick)\
**Post date:** [April 8, 2022, 7:15pm UTC](https://forum.gitea.com/t/password-is-required-to-clone-repository-using-ssh/5006/2 "2022-04-08T19:15:38Z")

</div>

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](https://docs.gitea.io/en-us/config-cheat-sheet/))

---

<div class="post-metadata">

**Author:** ![campos](https://avatars.discourse-cdn.com/v4/letter/c/7bcc69/32.png) [@campos](https://forum.gitea.com/u/campos)\
**Post date:** [April 8, 2022, 9:04pm UTC](https://forum.gitea.com/t/password-is-required-to-clone-repository-using-ssh/5006/3 "2022-04-08T21:04:28Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![FeRDNYC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/ferdnyc/32/2170_2.png) [@FeRDNYC](https://forum.gitea.com/u/FeRDNYC)\
**Post date:** [April 10, 2022, 6:59pm UTC](https://forum.gitea.com/t/password-is-required-to-clone-repository-using-ssh/5006/4 "2022-04-10T18:59:27Z")

</div>

> [@campos](#):
>
> 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.
