Question: 1. I would like to login to root via ssh directly while at home (192.168.1.0/24).
2. But while outside (e.g. at work), I can still login via ssh by using one of the custom accounts I created.

I jus tried:

```
Match Address 192.168.1.0/24
        PermitRootLogin yes

```

and now I'm completely locked out of the box. I can't login while at work and from home as well (I sshed into my other FreeBSD box).

Any ideas on how this can be done? Thank you

Answer: 
Check out the [AUTHORIZED\_KEYS FILE FORMAT](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/sshd.8#x415554484f52495a45445f4b4559532046494c4520464f524d4154) section of the sshd man page. Then add something like the following to `~root/.ssh/authorized_keys` (where the `ssh-ed25519 ...` part is replaced by your ssh public key):

```
from="192.168.1.0/24" ssh-ed25519 AA...

```

Then that key will only be allowed from your particular network.

Also, make sure you have the following in sshd\_config:

```
PermitRootLogin prohibit-password

```
The configuration change you made means "allow root from 192.168.1.0/24, deny everything else". In other words, only the conditions that match are allowed access.

You could try this instead:

```
AllowUsers root@192.168.1.? anotheruser1 anotheruser2

```

That means root from 192.168.1.0/24, and the other two users from anywhere.