Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
allowing ssh users based on IP
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
wesw02
Apprentice
Apprentice


Joined: 10 Nov 2004
Posts: 213
Location: Dayton, Ohio, USA

PostPosted: Wed Aug 03, 2005 5:24 am    Post subject: allowing ssh users based on IP Reply with quote

I have 2 servers on my lan, I'm setting up an RSA key so that i can cronjob my log files from server 1 to server 2 via scp, my goal with this project is to make the servers secure as possible; and for security reasons is it possible to have a user on server 2 that only accepts ssh connections from server 1, while accepting ssh connections for all other clients on a different user name? EX: the user 'log' only accepts connections from server1, but the user 'qwerty' accepts connections from all clients both via ssh. any ideas, sorry if it is confusing
Back to top
View user's profile Send private message
Xaid
Guru
Guru


Joined: 30 Oct 2004
Posts: 474
Location: Edmonton / Alberta

PostPosted: Wed Aug 03, 2005 5:31 am    Post subject: Reply with quote

I think the easiest approach would be to make a firewall with iptables and only allow connections on the ssh port from the IPs that you want.
If this is wrong, then someone correct me.
Back to top
View user's profile Send private message
wesw02
Apprentice
Apprentice


Joined: 10 Nov 2004
Posts: 213
Location: Dayton, Ohio, USA

PostPosted: Wed Aug 03, 2005 5:40 am    Post subject: Reply with quote

thats how i figured i would have to go about this, i was just hoping to allow my admin user name from all connections and my log user name from only the one, but i can live with that appoarch, i'll probably just end up adding a 3rd server for VPN and put these servers on a DMZ and use my VPN to access them from my lan. (of course only allowing port 80 & 21 in to the DMZ from the wan), I hope that made sense, lol
Back to top
View user's profile Send private message
Xaid
Guru
Guru


Joined: 30 Oct 2004
Posts: 474
Location: Edmonton / Alberta

PostPosted: Wed Aug 03, 2005 6:03 am    Post subject: Reply with quote

In my opinion, its not generally a good idea to allow the admin to login through SSH, so I disable it in my sshd.conf, this way, if someone tries to brute force their way in with the passwords, they'll need need two passwords to gain root instead of one (this is basically not always true since there could be an exploit in ssh that changes all that :)).
You should look into port knocking as well, there is a port knocking daemon in portage that you can check out, its net-misc/knock.

good luck.
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Wed Aug 03, 2005 6:26 am    Post subject: Reply with quote

are you searching for ...

man sshd_config wrote:
AllowUsers
This keyword can be followed by a list of user name patterns, separated by spaces.
If specified, login is allowed only for user names that match one of the patterns.
`*' and '?' can be used as wildcards in the patterns. Only user names are valid;
a numerical user ID is not recognized. By default, login is allowed for all users.
If the pattern takes the form USER@HOST then USER and HOST are separately checked,
restricting logins to particular users from particular hosts.

HTH
T.
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
rex123
Apprentice
Apprentice


Joined: 21 Apr 2004
Posts: 272

PostPosted: Wed Aug 03, 2005 8:14 am    Post subject: Reply with quote

If you are using publickey authentication, without passphrases (so that it can be run via cron), and taking into account the fact that you say "my goal with this project is to make the servers secure as possible", you might want to restrict the commands that can be run as well. Look into man 8 sshd for details on how to do this using the authorized_keys(2) file.
Back to top
View user's profile Send private message
wesw02
Apprentice
Apprentice


Joined: 10 Nov 2004
Posts: 213
Location: Dayton, Ohio, USA

PostPosted: Wed Aug 03, 2005 9:12 pm    Post subject: Reply with quote

Xaid wrote:
In my opinion, its not generally a good idea to allow the admin to login through SSH, so I disable it in my sshd.conf, this way, if someone tries to brute force their way in with the passwords, they'll need need two passwords to gain root instead of one (this is basically not always true since there could be an exploit in ssh that changes all that :)).
You should look into port knocking as well, there is a port knocking daemon in portage that you can check out, its net-misc/knock.

good luck.


I did not mean root (root logins are disabled), i meant my admin name, just didn't feel like releasing the name.

Quote:

are you searching for ...

man sshd_config wrote:
Quote:

AllowUsers
This keyword can be followed by a list of user name patterns, separated by spaces.
If specified, login is allowed only for user names that match one of the patterns.
`*' and '?' can be used as wildcards in the patterns. Only user names are valid;
a numerical user ID is not recognized. By default, login is allowed for all users.
If the pattern takes the form USER@HOST then USER and HOST are separately checked,
restricting logins to particular users from particular hosts.

HTH
T.


so would this work to allow the loguser to only login from server1 and the adminuser from a lan workstation (would it block all other connects such as 87.45.25.15):
Code:

AllowUsers       adminuser@192.168.0.*
AllowUsers       loguser@server1
Back to top
View user's profile Send private message
rex123
Apprentice
Apprentice


Joined: 21 Apr 2004
Posts: 272

PostPosted: Thu Aug 04, 2005 8:15 am    Post subject: Reply with quote

wesw02 wrote:
so would this work ...

Why not try it, then tell the rest of us?
Back to top
View user's profile Send private message
wesw02
Apprentice
Apprentice


Joined: 10 Nov 2004
Posts: 213
Location: Dayton, Ohio, USA

PostPosted: Thu Aug 04, 2005 7:41 pm    Post subject: Reply with quote

Quote:

Quote:

wesw02 wrote:
so would this work ...

Why not try it, then tell the rest of us?


sorry, haven't been home, been away at college, i will let you know this weekend.
Back to top
View user's profile Send private message
vaguy02
Guru
Guru


Joined: 25 Feb 2005
Posts: 424
Location: Hopefully in one place

PostPosted: Fri Aug 05, 2005 7:43 pm    Post subject: Reply with quote

I allow root access through ssh. I prevent brute force attacks on root or any other account is after 3 failed attempts, my computer automatically bans the IP from the computer for 24 hours. It's much harder to accomplish than some of the other suggestions given, but I think it works well. Just a though.
Back to top
View user's profile Send private message
wesw02
Apprentice
Apprentice


Joined: 10 Nov 2004
Posts: 213
Location: Dayton, Ohio, USA

PostPosted: Sun Aug 07, 2005 3:17 am    Post subject: Reply with quote

rex123 wrote:
wesw02 wrote:
so would this work ...

Why not try it, then tell the rest of us?


works prefect, thanks for the help

vaguy09, how did you manage that? is it a simple config, or a script. (sorry if I seem like a newbie, still trying to get a good hold on network security)
Back to top
View user's profile Send private message
vaguy02
Guru
Guru


Joined: 25 Feb 2005
Posts: 424
Location: Hopefully in one place

PostPosted: Sun Aug 07, 2005 4:03 pm    Post subject: Reply with quote

No, It's actually a combination of snort, snortsam, base(used to be acid), and mysql. it was a pain to configure, but it works well once it does work.
Back to top
View user's profile Send private message
wesw02
Apprentice
Apprentice


Joined: 10 Nov 2004
Posts: 213
Location: Dayton, Ohio, USA

PostPosted: Sun Aug 07, 2005 8:46 pm    Post subject: Reply with quote

Sounds complex, but nice. I might have to give something like that a try :D
Back to top
View user's profile Send private message
vaguy02
Guru
Guru


Joined: 25 Feb 2005
Posts: 424
Location: Hopefully in one place

PostPosted: Sun Aug 07, 2005 8:57 pm    Post subject: Reply with quote

Yeah, I mean it took me about a week to get it all figured out. but it's nice now. anyways, if you run into problems or need help just message me or something and I will help you if I can.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum