Skip to content

[openssh] deny password login unless attempt is from local the network

This is not an Arch Linux question.

I have an Arch server which I can access from outside the local network using ssh. I like to reject password based ssh-attempts from outside the local network. Can this be done?

0 points9 comments
Open on Reddit
About this post
Posted
Archived
Score
0 · 100% up
Kind
Text
ID
dnwm01

Author

49
posts
107
comments
0
media
View profile

9 comments

Are you trying to allow key based access from outside of the LAN and use passwords inside? I would just use ssh-keygen to generate keys and disallow passwords altogether. Otherwise you could just block the port in your router or firewall

2 points

I like to have only keybased ssh access from outside the lan. From the inside I don't mind if it is keybased or password based.

1 points

Check the "match" option in the sshd config. This can do what you want.

3 points

In that case, you can do this with the match directive in the sshd.conf

1 points

So, I attempted to access the ssh server from outside my lan today. This failed :( The server is listening on a custom port. The laptop I use can access the server from the lan with ecsda key (port 22) But from the outside I got:

"ECSDA host key for ip address " xx" not in list of known hosts"

Is there a config option to make host key checking less strict? I mean, when travelling I have no control over the ip address I am assigned. Or is it the (external) ip address of the router that is not in the list? That ip address changes less frequently, I guess. But I have no control over it ... how to get around this?

1 points

I'm not am expert, but I believe the IP is part of the fingerprint to avoid man-in-the-middle attacks. I believe that you can remove the key of a known host using ssh-keygen -R IP (or similar, don't really remember the syntax). I don't know if there's a way to disable it. Does it not just ask if you want to proceed anyway?

1 points

Match keyword.

I would advise against developing a system that assumes everything on the LAN is secure/trustworthy and stick with the less complex and proveably secure setup using only key-based auth.

2 points

Consider doing some form of 2fa for the password login. U2f, fido2, otp pad or similar. This can actually be better than using keys from external machines if you are working on less than trusted devices. Accessing your private key from some random device might not be the best idea after all.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.