# Setting up git user for ssh access

**URL:** <https://forum.gitea.com/t/setting-up-git-user-for-ssh-access/326>\
**Category:** Install/Maintain/Configure\
**Created:** [June 7, 2018, 4:07pm UTC](https://forum.gitea.com/t/setting-up-git-user-for-ssh-access/326 "2018-06-07T16:07:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![radon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/radon/32/4742_2.png) [@radon](https://forum.gitea.com/u/radon)\
**Post date:** [June 7, 2018, 4:07pm UTC](https://forum.gitea.com/t/setting-up-git-user-for-ssh-access/326/1 "2018-06-07T16:07:01Z")

</div>

Hello,

I’d like to set up the git user in a way, that it can do push/clone and all necessary git features, but not access the server through ssh in any common way, which it can with default configuration. (I realize this is more a linux issue than gitea-specific, but I hope that here is a good place to ask this nontheless)

Currently, I use the shell /usr/sbin/nologin for the user git, which allows the user to run the gitea application. If I try to ssh into the server, I get this, which is what I had desired:

```
$ ssh git.myserver.de
PTY allocation request failed on channel 0
This account is currently not available.
Connection to git.myserver.de closed.

```

However, I can’t use the ssh url to clone a gitea repo for obvious reasons:

```
$ git clone ssh://git@git.myserver.de/user/repo.git
Cloning into 'repo'...
fatal: protocol error: bad line length character: This

```

So how would I keep the regular ssh functionality disabled while allowing access to git-specific functionalities? Is there a specific shell that would allow me to accomplish this?

//edit

I think i might have jumped the gun on this and didnt realize that this feature is provided by default with a regular shell. I feel kinda stupid now.

---

<div class="post-metadata">

**Author:** ![Linkjay](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/linkjay/32/173_2.png) [@Linkjay](https://forum.gitea.com/u/Linkjay)\
**Post date:** [June 10, 2018, 3:01am UTC](https://forum.gitea.com/t/setting-up-git-user-for-ssh-access/326/2 "2018-06-10T03:01:50Z")

</div>

I figure you have already fixed this, but I would like to confirm for you.

I setup my SSH access on Gitea using this guide: [https://wiki.archlinux.org/index.php/Gitea#Enable\_SSH\_Support](https://wiki.archlinux.org/index.php/Gitea#Enable_SSH_Support) .

Don’t worry about it being Arch Linux, just do what you do for your own configuration. I did mine on Ubuntu and it works perfectly.

To confirm, yes you will have an SSH-available user, but no, there will be no shell access, even if Gitea is stopped. I confirmed, and there is no access available on SFTP either.

Following the guide I have linked, you should have a fully-working Git interface over SSH, with no access to anything else on the machine.

---

<div class="post-metadata">

**Author:** ![Alexey](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Alexey](https://forum.gitea.com/u/Alexey)\
**Post date:** [September 18, 2023, 3:44pm UTC](https://forum.gitea.com/t/setting-up-git-user-for-ssh-access/326/3 "2023-09-18T15:44:54Z")

</div>

> [@radon](#):
>
> ```auto
> $ ssh git.myserver.de
> PTY allocation request failed on channel 0
> This account is currently not available.
> Connection to git.myserver.de closed.
> 
> ```

This means you don’t have shell for you user.  
You can try to

```auto
cat /etc/passwd

```

and look at your user.

```auto
$ git clone ssh://git@git.myserver.de/user/repo.git
Cloning into 'repo'...
fatal: protocol error: bad line length character: This

```

I get the same prombem and don’t know how to fix it.  
**fatal: protocol error: bad line length character: This**  
Maybe someone know where is the problem?  
I use VSCode in my win10 desktop.

---

<div class="post-metadata">

**Author:** ![Alexey](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Alexey](https://forum.gitea.com/u/Alexey)\
**Post date:** [September 18, 2023, 4:12pm UTC](https://forum.gitea.com/t/setting-up-git-user-for-ssh-access/326/4 "2023-09-18T16:12:23Z")

</div>

Try to use you link, my config sshd\_config are here

```auto
# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes
UsePAM yes
AllowUsers gitea

```

UsePAM yes  
AllowUsers gitea  
from link below, but still have  
**fatal: protocol error: bad line length character: This**

---

<div class="post-metadata">

**Author:** ![Alexey](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Alexey](https://forum.gitea.com/u/Alexey)\
**Post date:** [September 18, 2023, 11:23pm UTC](https://forum.gitea.com/t/setting-up-git-user-for-ssh-access/326/5 "2023-09-18T23:23:13Z")

</div>

1. my error message was “This account is currently not available.”
2. I create user with this options:

```auto
adduser --system --group --disabled-password --home /etc/gitea gitea

```

without any shell.  
The right way is:

```auto
adduser --system --shell /bin/bash --group --disabled-password --home /etc/gitea gitea

```

Thats why i can’t get via ssh.
