Ssh not working in centos


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:// 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?


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. :grinning:

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


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


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

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

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…?


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…


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


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

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 ?


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


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

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):