# IP restriction for repo via SSH

**URL:** <https://forum.gitea.com/t/ip-restriction-for-repo-via-ssh/1335>\
**Category:** General\
**Created:** [July 27, 2019, 10:20pm UTC](https://forum.gitea.com/t/ip-restriction-for-repo-via-ssh/1335 "2019-07-27T22:20:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dima](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dima](https://forum.gitea.com/u/Dima)\
**Post date:** [July 27, 2019, 10:20pm UTC](https://forum.gitea.com/t/ip-restriction-for-repo-via-ssh/1335/1 "2019-07-27T22:20:44Z")

</div>

Hello.

Help, please, is there any way to make a restriction on the IP for repository through SSH?

---

<div class="post-metadata">

**Author:** ![lafriks](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/lafriks/32/3004_2.png) [@lafriks](https://forum.gitea.com/u/lafriks)\
**Post date:** [July 29, 2019, 10:38am UTC](https://forum.gitea.com/t/ip-restriction-for-repo-via-ssh/1335/2 "2019-07-29T10:38:00Z")

</div>

you can block connections except for allowed set of IP addresses to SSH port using firewall (ex. iptables)

---

<div class="post-metadata">

**Author:** ![Dima](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dima](https://forum.gitea.com/u/Dima)\
**Post date:** [July 29, 2019, 4:52pm UTC](https://forum.gitea.com/t/ip-restriction-for-repo-via-ssh/1335/3 "2019-07-29T16:52:44Z")

</div>

Yes, it’s if need block totally. But how can do if need for repo1 provide access only from IP 1.1.1.1 and for repo2 from 2.2.2.2 for example? And 1.1.1.1 can’t use SSH for repo2, and 2.2.2.2 can’t got repo2

---

<div class="post-metadata">

**Author:** ![BasicBaer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/basicbaer/32/600_2.png) [@BasicBaer](https://forum.gitea.com/u/BasicBaer)\
**Post date:** [July 30, 2019, 11:34am UTC](https://forum.gitea.com/t/ip-restriction-for-repo-via-ssh/1335/4 "2019-07-30T11:34:42Z")

</div>

If you do not use the builtin SSH server but the one of the hosting system you can define a list of allowed source IPs per username. You could even go so far as to not use the authorized\_keys tool but have the list exported regularly by gitea and then munch that through some script to also add limitations per repository. But honestly that is a lot of work and I am not sure it would be worth the while.

Cheers

BasicBaer

---

<div class="post-metadata">

**Author:** ![Dima](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dima](https://forum.gitea.com/u/Dima)\
**Post date:** [July 30, 2019, 2:14pm UTC](https://forum.gitea.com/t/ip-restriction-for-repo-via-ssh/1335/5 "2019-07-30T14:14:38Z")

</div>

Yes, i’m use builtin SSH server on own Ubuntu server. And can’t find way how make this kind of restriction ☹

---

<div class="post-metadata">

**Author:** ![BasicBaer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/basicbaer/32/600_2.png) [@BasicBaer](https://forum.gitea.com/u/BasicBaer)\
**Post date:** [July 31, 2019, 12:55pm UTC](https://forum.gitea.com/t/ip-restriction-for-repo-via-ssh/1335/6 "2019-07-31T12:55:13Z")

</div>

Dima, I would suggest to move to the external, OS provided SSH service. IMHO it is more trustworthy and quite more flexible conserning the configurations.

---

<div class="post-metadata">

**Author:** ![Dima](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dima](https://forum.gitea.com/u/Dima)\
**Post date:** [July 31, 2019, 1:08pm UTC](https://forum.gitea.com/t/ip-restriction-for-repo-via-ssh/1335/7 "2019-07-31T13:08:10Z")

</div>

Thank you, i will try it.
