# Ssh not working in centos

**URL:** <https://forum.gitea.com/t/ssh-not-working-in-centos/527>\
**Category:** Install/Maintain/Configure\
**Created:** [August 24, 2018, 4:55am UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527 "2018-08-24T04:55:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vmuthu](https://avatars.discourse-cdn.com/v4/letter/v/aca169/32.png) [@vmuthu](https://forum.gitea.com/u/vmuthu)\
**Post date:** [August 24, 2018, 4:55am UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527/1 "2018-08-24T04:55:35Z")

</div>

Hello,  
I have managed to install gitea to a CentOs linux instance and also configured nginx to serve the site through a url. I am able to clone a url via http, but not via ssh.  
The server uses a different port than 22 for connecting to linux and I use that port as SSH\_PORT in the app.ini file. I also made sure the ssh url ssh://git@domain.name.com:/root/TestRepository.git uses the correct port and domain names.  
I am able to pull/push and raise PR and merge using http push. But unable to connect via ssh. Do you have any idea why it won’t work?  
I have a doubt if I have to use a different port and use the built in ssh server in linux? Is this right?  
I also noticed that when the clone ssh command is run in command line, it asks for the linux user’s password… So does it mean I should run embedded ssh server for gitea?

---

<div class="post-metadata">

**Author:** ![mark](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mark](https://forum.gitea.com/u/mark)\
**Post date:** [August 24, 2018, 10:28am UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527/2 "2018-08-24T10:28:48Z")

</div>

Encountered a similar issue, although i use the standard port 22. Meaning I am not replying on a probable cause for this specific configuration. just sharing a my cause. 😀

My issue was the home directory of the user running of gitea and the Root Path / Working Dir (where gitea stores ssh keys) did not match. As admin user in gitea in Site Administration \> Configuration the admin panel look for the Root Path in section “SSH Configuration”.

check the home directory of the user running gitea

`eval echo "~your_gitea_run_user"`

if there is a mismatch, set the home dir to your working dir

`usermod -d /your_working_dir your_gitea_run_user`

---

<div class="post-metadata">

**Author:** ![vmuthu](https://avatars.discourse-cdn.com/v4/letter/v/aca169/32.png) [@vmuthu](https://forum.gitea.com/u/vmuthu)\
**Post date:** [August 24, 2018, 11:36am UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527/3 "2018-08-24T11:36:52Z")

</div>

Hmm, my configuration has the following  
gitea username: git  
ssh Root Path: /home/git/.ssh  
home directory of git : /home/git  
git user has rw permissions on this folder

---

<div class="post-metadata">

**Author:** ![mark](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mark](https://forum.gitea.com/u/mark)\
**Post date:** [August 24, 2018, 11:43am UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527/4 "2018-08-24T11:43:57Z")

</div>

> [@vmuthu](#):
>
> gitea username: git  
> ssh Root Path: /home/git/.ssh  
> home directory of git : /home/git  
> git user has rw permissions on this folder

This is oke, so your issue is not the one i faced 😟

btw : my url for ssh (translated to your example) is simply

`git@domain.name.com:/root/TestRepository.git`

and if you are really using “root” is ssh for root access enabled? (normally it is on centos)

EDIT: did you think about opening the port in firewald, if it is running…?

---

<div class="post-metadata">

**Author:** ![vmuthu](https://avatars.discourse-cdn.com/v4/letter/v/aca169/32.png) [@vmuthu](https://forum.gitea.com/u/vmuthu)\
**Post date:** [August 24, 2018, 12:13pm UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527/5 "2018-08-24T12:13:51Z")

</div>

lol, if you ask me about firewalld, that was the first thing I messed up. The ssh port was different in the instance and it was not pre-installed/configured with firewalld. So the first thing I did was to enable firewalld and lose access!! Anyways the hosting company helped me in restoring and things are fine.  
So yes, the firewall has the tcp/udp ports open for ssh port and also http.  
I can’t get what you mean by " if you are really using “root” is ssh for root access enabled? (normally it is on centos)"  
I login to the terminal with ssh using root user. I have created a user named git without password and made it the owner of the gitea home etc., So now my problem is it is asking for the password of a user for which I don’t have one…

---

<div class="post-metadata">

**Author:** ![linuxpython](https://avatars.discourse-cdn.com/v4/letter/l/9fc348/32.png) [@linuxpython](https://forum.gitea.com/u/linuxpython)\
**Post date:** [August 24, 2018, 1:03pm UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527/6 "2018-08-24T13:03:09Z")

</div>

Did you check for problems with SELinux? On CentOS, it’s enforcing by default.

---

<div class="post-metadata">

**Author:** ![mark](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mark](https://forum.gitea.com/u/mark)\
**Post date:** [August 24, 2018, 1:03pm UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527/7 "2018-08-24T13:03:12Z")

</div>

> [@vmuthu](#):
>
> So the first thing I did was to enable firewalld and lose access!!

been there, done this (it’s quite embarrassing)

> [@vmuthu](#):
>
> I can’t get what you mean by " if you are really using “root” is ssh for root access enabled? (normally it is on centos)"  
> I login to the terminal with ssh using root user.

So you are good, other distro’s and some vps providers are very picky on ssh in as root

this is how i created the gitea run user (translated to your setup):

```
useradd -r -s /bin/bash \
-d /home/git \
-c "Gitea git account" git

```

and the key you have uploaded for _root_ using the web-gui can be found in:  
`cat /home/git/.ssh/authorized_keys` ?

---

<div class="post-metadata">

**Author:** ![vmuthu](https://avatars.discourse-cdn.com/v4/letter/v/aca169/32.png) [@vmuthu](https://forum.gitea.com/u/vmuthu)\
**Post date:** [August 24, 2018, 1:19pm UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527/8 "2018-08-24T13:19:09Z")

</div>

yes, that was exactly I created the user too.

And the /home/git/.ssh/authorized\_keys displays the key I added for ssh on the web user/settings/keys SSH Key section

---

<div class="post-metadata">

**Author:** ![mark](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mark](https://forum.gitea.com/u/mark)\
**Post date:** [August 30, 2018, 6:47pm UTC](https://forum.gitea.com/t/ssh-not-working-in-centos/527/9 "2018-08-30T18:47:30Z")

</div>

> [@vmuthu](#):
>
> ssh://git@domain.name.com:/root/TestRepository.git

Sorry was busy with other stuff before getting to test your issue using a custom ssh port . 😟

after changing the port gitea is so smart to update the ssh url correctly;  
i’v changed my default sshd port on centos to 2222 and gitea gives me (translated to your example):

ssh://git@domain.name.com:2222/root/TestRepository.git
