Recently, I could not get ssh working with gitea. I got all sorts of
error - Connection timed out
,
Too many authentication failure
, ssh freezing, et al. Stuff
I never encountered with github. ssh worked on its own, and so did
gitea’s username-password authentication. Assuming yours does too, here
is how you can troubleshoot this.
If you haven’t, generate a key
ssh-keygen -t ed25519 -C "your key's label"
, and add it to
your gitea instance at the web endpoint
/user/settings/keys
. This will create an entry in the file
/home/<gitea user>/.ssh/authorized_keys
.
Run sudo nano /etc/ssh/sshd_config
to allow connections
from your gitea system user. My gitea user is called “git”. If you don’t
know what your gitea user is called, look for RUN_USER
inside sudo nano /etc/gitea/app.ini
. You can also look at
who owns gitea’s data files with
ls -la /var/lib/gitea/data
. This should match the
RUN_USER
.
PermitRootLogin no
AllowUsers abc def git
...
Make sure ~/.ssh
has the correct permissions set,
sudo chmod -R 700 ~/.ssh
sudo chmod 640 ~/.ssh/authorized_keys
sudo sudo chown -R $USER ~/.ssh/
Restart ssh.
Add a config entry to ~/.ssh/ssh_config
Host gitea # call this whatever you'd like
HostName 192.168.1.77
User git # matches the ssh AllowUsers directive
Port 7778
IdentityFile ~/.ssh/gitea
Now git commands should work.
# git remote add originssh git@<host name from your ssh_config, mine is gitea>:<gitea web user>/<repo name>.git
git remote add originssh git@gitea:n00b/guides.git
git pull origin master
References,