View previous topic :: View next topic |
Author |
Message |
wesw02 Apprentice
Joined: 10 Nov 2004 Posts: 213 Location: Dayton, Ohio, USA
|
Posted: Wed Aug 03, 2005 5:24 am Post subject: allowing ssh users based on IP |
|
|
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 |
|
|
Xaid Guru
Joined: 30 Oct 2004 Posts: 474 Location: Edmonton / Alberta
|
Posted: Wed Aug 03, 2005 5:31 am Post subject: |
|
|
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 |
|
|
wesw02 Apprentice
Joined: 10 Nov 2004 Posts: 213 Location: Dayton, Ohio, USA
|
Posted: Wed Aug 03, 2005 5:40 am Post subject: |
|
|
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 |
|
|
Xaid Guru
Joined: 30 Oct 2004 Posts: 474 Location: Edmonton / Alberta
|
Posted: Wed Aug 03, 2005 6:03 am Post subject: |
|
|
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 |
|
|
think4urs11 Bodhisattva
Joined: 25 Jun 2003 Posts: 6659 Location: above the cloud
|
Posted: Wed Aug 03, 2005 6:26 am Post subject: |
|
|
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 |
|
|
rex123 Apprentice
Joined: 21 Apr 2004 Posts: 272
|
Posted: Wed Aug 03, 2005 8:14 am Post subject: |
|
|
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 |
|
|
wesw02 Apprentice
Joined: 10 Nov 2004 Posts: 213 Location: Dayton, Ohio, USA
|
Posted: Wed Aug 03, 2005 9:12 pm Post subject: |
|
|
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 |
|
|
rex123 Apprentice
Joined: 21 Apr 2004 Posts: 272
|
Posted: Thu Aug 04, 2005 8:15 am Post subject: |
|
|
wesw02 wrote: | so would this work ... |
Why not try it, then tell the rest of us? |
|
Back to top |
|
|
wesw02 Apprentice
Joined: 10 Nov 2004 Posts: 213 Location: Dayton, Ohio, USA
|
Posted: Thu Aug 04, 2005 7:41 pm Post subject: |
|
|
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 |
|
|
vaguy02 Guru
Joined: 25 Feb 2005 Posts: 424 Location: Hopefully in one place
|
Posted: Fri Aug 05, 2005 7:43 pm Post subject: |
|
|
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 |
|
|
wesw02 Apprentice
Joined: 10 Nov 2004 Posts: 213 Location: Dayton, Ohio, USA
|
Posted: Sun Aug 07, 2005 3:17 am Post subject: |
|
|
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 |
|
|
vaguy02 Guru
Joined: 25 Feb 2005 Posts: 424 Location: Hopefully in one place
|
Posted: Sun Aug 07, 2005 4:03 pm Post subject: |
|
|
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 |
|
|
wesw02 Apprentice
Joined: 10 Nov 2004 Posts: 213 Location: Dayton, Ohio, USA
|
Posted: Sun Aug 07, 2005 8:46 pm Post subject: |
|
|
Sounds complex, but nice. I might have to give something like that a try |
|
Back to top |
|
|
vaguy02 Guru
Joined: 25 Feb 2005 Posts: 424 Location: Hopefully in one place
|
Posted: Sun Aug 07, 2005 8:57 pm Post subject: |
|
|
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 |
|
|
|