View previous topic :: View next topic |
Author |
Message |
grant123 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 23 Mar 2005 Posts: 1099
|
Posted: Sun Mar 02, 2014 2:41 am Post subject: SSH via root |
|
|
Can I configure SSH to allow password access for one user and keys access for root?
Can I have SSH root access require a password and keys? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
NeddySeagoon Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
![](images/avatars/3946266373f47d606a2db3.jpg)
Joined: 05 Jul 2003 Posts: 54834 Location: 56N 3W
|
Posted: Sun Mar 02, 2014 10:01 am Post subject: |
|
|
grant123,
Any ssh access for root it doing it wrong.
Add users you want be be able to gain root access to the wheel group and install and set up sudo.
Users in the wheel group can now do and give their own password to become root with roots environment.
If you enable both key based and password based logins, ssh will prefer keys and fall back to passwords. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
666threesixes666 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/48510216954a8919d65183.jpg)
Joined: 31 May 2011 Posts: 1248 Location: 42.68n 85.41w
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
NeddySeagoon Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
![](images/avatars/3946266373f47d606a2db3.jpg)
Joined: 05 Jul 2003 Posts: 54834 Location: 56N 3W
|
Posted: Sun Mar 02, 2014 10:47 am Post subject: |
|
|
666threesixes666,
I disable remote access for root an all my systems but permit console access for root.
I can't remember the last time I used a root login (I've forgotten my root passwords).
To log in via ssh an attacker needs two things, a user name and a password.
If root logins are permitted, the attacker already has 50% of the information to log in.
In my opinion, making wheel group users sudo nopasswd is a step too far.
When I do the odd root command with sudo command, I like the reminder that the password prompt provides.
Its no extra security, since an attacker that is in a wheel users account already has a password collision. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
krinn Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
![](images/avatars/gallery/Blade Runner/movie_blade_runner_howl.gif)
Joined: 02 May 2003 Posts: 7470
|
Posted: Sun Mar 02, 2014 1:12 pm Post subject: Re: SSH via root |
|
|
grant123 wrote: | Can I configure SSH to allow password access for one user and keys access for root? |
You can enable both password and key access, as ssh try always key prior to password, having a valid key for root and none for the user will make it key access for root and by password only for user.
If you're going for keys only for root and password only for user, then i don't know, as invalid key for root will backup to password access for root. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
krinn Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
![](images/avatars/gallery/Blade Runner/movie_blade_runner_howl.gif)
Joined: 02 May 2003 Posts: 7470
|
Posted: Sun Mar 02, 2014 1:18 pm Post subject: |
|
|
NeddySeagoon wrote: |
To log in via ssh an attacker needs two things, a user name and a password.
If root logins are permitted, the attacker already has 50% of the information to log in.
|
But the numbers are flow because of the strength of the next 50% part of the problem :
root account is known but its password is certainly stronger than a random user.
and from what i see in my own log, people prefer trying to guess a user name that would then allow them to bet on a weak password than attacking the root itself.
Sure one could use 12356 as password for root, but people put their bet to met it more with "pamela" account than root one. (no offense to any pamela's mind here, that's an example). |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Anon-E-moose Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
![](images/avatars/3064969284ad468b81342a.jpg)
Joined: 23 May 2008 Posts: 6222 Location: Dallas area
|
Posted: Sun Mar 02, 2014 1:23 pm Post subject: |
|
|
For the most part, I keep ssh locked to only access for the local network.
I have gone out of town and visited people, and when that happened,
I took the time to try and look at the range of IPs that would be available and set it up to allow only those.
I'm in the USA, I certainly wouldn't set up potential access for use outside this country.
I know everybodies different, but there are other things to do to tighten up security. _________________ UM780, 6.12 zen kernel, gcc 13, openrc, wayland |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23093
|
Posted: Sun Mar 02, 2014 4:31 pm Post subject: |
|
|
When using sudo, I prefer sudo -i over sudo su -. It is shorter and both result in an interactive root shell, assuming the right password and permissions.
For requiring keys for root, sshd has the special option PermitRootLogin without-password, which prohibits password-based root authentication. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
mv Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
![](images/avatars/169262237648b51b40d0ec0.png)
Joined: 20 Apr 2005 Posts: 6780
|
Posted: Sun Mar 02, 2014 6:46 pm Post subject: |
|
|
NeddySeagoon wrote: | Any ssh access for root it doing it wrong. |
I don't agree: root access is the only way to allow rsync for all files without jumping loops.
Quote: | If root logins are permitted, the attacker already has 50% of the information to log in. |
I would say: If this gives 50% of the information then you are doing something wrong.
More precisely, a typical user name is 6 symbols, all lowercase, which means 3-4 bytes of actual informatino. For any secret (no matter whether it is a password or a shared key), adding 3-4 bytes redundancy to the data can hardly change it from "insecure" to "secure". Using a longer key instead should add much more to your security than 3-4 bytes. Considering the username as part of the secret is just "security by obscurity". |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
NeddySeagoon Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
![](images/avatars/3946266373f47d606a2db3.jpg)
Joined: 05 Jul 2003 Posts: 54834 Location: 56N 3W
|
Posted: Sun Mar 02, 2014 7:07 pm Post subject: |
|
|
mv,
Quote: | If this gives 50% of the information then you are doing something wrong |
You are correct. If you consider the username and password/key as part of the single secret needed to log in, the username is only a small part of the secret. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
grant123 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 23 Mar 2005 Posts: 1099
|
Posted: Mon Mar 03, 2014 2:45 pm Post subject: |
|
|
Quote: | I don't agree: root access is the only way to allow rsync for all files without jumping loops. |
Exactly, that's what I'm doing. I wish I could require both keys and a password for root. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
SirRobin2318 Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 24 Apr 2004 Posts: 241 Location: Strasbourg, france.
|
Posted: Mon Mar 03, 2014 2:54 pm Post subject: |
|
|
You can password protect your ssh keys when you generate them. So your sshd conf would only allow key authentication, but on the client side, when using that key, you'd be required to enter a password to unlock it. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
grant123 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 23 Mar 2005 Posts: 1099
|
Posted: Mon Mar 03, 2014 5:34 pm Post subject: |
|
|
So if I configure the server with 'PermitRootLogin without-password' and specify a password when generating the keys, the client would be required to have the private key and enter the password when connecting? This password prompt is just like the normal SSH password prompt? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
SirRobin2318 Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 24 Apr 2004 Posts: 241 Location: Strasbourg, france.
|
Posted: Mon Mar 03, 2014 6:01 pm Post subject: |
|
|
Yes, that's it. Give it a try to see if it works as intended. Note that the client can have ssh-agent to remember the password. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
1clue Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Mon Mar 03, 2014 6:13 pm Post subject: |
|
|
Try changing the port of sshd. Put it in the 5-digit range for ports, which basically means nobody is going to scan that high. IMO the absolutely biggest security hole in ssh is a default port.
I would go through any amount of effort to not allow root login from remote under any circumstance, for any reason. Sudo is enough. There are two things I really like about Ubuntu: The first is disabled root account. You can't even log in as root on the terminal. The second is that you can install it in about 5 minutes, but that's not part of this discussion. The presence of a root account which can be used as login is a security nightmare for any IT shop. When somebody gets fired, what you gonna do? Change all root passwords on all the UN*X boxes? That's not rational.
Root login having better passwords: I call BS on that. Root login has no forced password validation. I know several people who use 2 or 3 character passwords for root, and in one case I know both characters are on the home row. Worse yet, this is a business network, and he uses "some two-character combination on the home row" for all his accounts on that network, and had done so for several years. Or i should qualify: He did when I worked with him, and since that was a few years back he might have changed his behavior since.
I've ranted at people for bad passwords for my entire professional IT carreer, which started in the mid 90s. The only way they'll ever change their behavior is to be owned in a huge way with big consequences ($$$), where their bad security is the only possible explanation. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23093
|
Posted: Tue Mar 04, 2014 3:40 am Post subject: |
|
|
1clue wrote: | I would go through any amount of effort to not allow root login from remote under any circumstance, for any reason. Sudo is enough. | As already stated above, sudo is not enough in some cases. I know of no way to allow privileged rsync using sudo to elevate the remote side.
1clue wrote: | There are two things I really like about Ubuntu: The first is disabled root account. You can't even log in as root on the terminal. The second is that you can install it in about 5 minutes, but that's not part of this discussion. The presence of a root account which can be used as login is a security nightmare for any IT shop. When somebody gets fired, what you gonna do? Change all root passwords on all the UN*X boxes? That's not rational. | I consider sudo to be a security weakness for the fact that it reuses the individual account password as an authorization password. Changing the root password is not your biggest problem. Your biggest problem is that someone who had privileged access to do anything to the systems is now gone under bad terms. If the now ex-employee had no ill intent, you could leave the root passwords unchanged and it would not matter. If he had ill intent, he could have arranged any number of backdoors or time bombs on the system. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
1clue Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Tue Mar 04, 2014 4:05 am Post subject: |
|
|
Hu wrote: | 1clue wrote: | I would go through any amount of effort to not allow root login from remote under any circumstance, for any reason. Sudo is enough. | As already stated above, sudo is not enough in some cases. I know of no way to allow privileged rsync using sudo to elevate the remote side.
|
I'm not convinced that a wrapper script on the remote end couldn't handle that.
Quote: |
1clue wrote: | There are two things I really like about Ubuntu: The first is disabled root account. You can't even log in as root on the terminal. The second is that you can install it in about 5 minutes, but that's not part of this discussion. The presence of a root account which can be used as login is a security nightmare for any IT shop. When somebody gets fired, what you gonna do? Change all root passwords on all the UN*X boxes? That's not rational. | I consider sudo to be a security weakness for the fact that it reuses the individual account password as an authorization password. Changing the root password is not your biggest problem. Your biggest problem is that someone who had privileged access to do anything to the systems is now gone under bad terms. If the now ex-employee had no ill intent, you could leave the root passwords unchanged and it would not matter. If he had ill intent, he could have arranged any number of backdoors or time bombs on the system. |
Sudo is certainly no more risky than a shared root password. For one thing, with a shared root password you have no way to find out who it was who originally instigated some sort of bad behavior. And with sudo, you can shut down the bad guy before he has a chance to fire off a trigger to all those time bombs. Backdoors are a risk in either case.
I guess in my experience, I've never seen any evidence of premeditated time bombs on company equipment. I worked with a guy who claimed he had, but he liked to blow steam every now and then, and bragging that sort of thing in a break room belies the cleverness of putting in those bombs.
Another benefit of sudo is the ability to provide limited access rather than all or nothing.
The sudo debate has been going on for forever. I'm sold on it, and you're not. Let it rest there. We could get back on topic that way. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
1clue Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Tue Mar 04, 2014 4:41 am Post subject: |
|
|
Sorry for the double post. I hadn't really finished my thought.
Premeditated time bombs: In my experience, the IT guy who gets fired is usually either lazy and doesn't do enough (not likely to bother with a back door or time bomb), or not clever enough (no chance of a real back door or time bomb) or suddenly snaps and gets nasty all of a sudden.
I'm not saying premeditated boobytraps are impossible, but rather that doing something like that is illegal at best and criminal in the right circumstances. And probably traceable if you're using sudo.
Unlimited rsync: I can't help but think that if you need this, you're doing it wrong. Allowing rsync to access any file on the system just seems like an invitation to black hats. Backups? Start it on the client and upload a file with an unprivileged account. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
szatox Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 27 Aug 2013 Posts: 3498
|
Posted: Tue Mar 04, 2014 8:46 am Post subject: |
|
|
grant123 wrote: | I wish I could require both keys and a password for root. |
1) disable remote login on root
2) force passwor-less login on user (I suppose it's possible to force it on a particular group only, in case you needed pasword login as well)
3) Login on user account with key
4) use either su or sudo to get root priviliges
So, you need user key and either user pasword or root password to login as root.
Now, key alone should be secure enough to make password expendable, and breaking standards is just a bad idea. Don't change ssh port, use tools you already have. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
666threesixes666 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/48510216954a8919d65183.jpg)
Joined: 31 May 2011 Posts: 1248 Location: 42.68n 85.41w
|
Posted: Tue Mar 04, 2014 9:15 am Post subject: |
|
|
i was experimenting with pam today to throttle root failed login attempts. problem with what i was doing was it would lock everyone out of root, not specific ip addresses or what ever.... keys could still get in, and sudo su could still get in, but su was completely barred of entry. i have the clues and pieces to wrap together some sort of policy but i haven't really thought through what should be done with that if anything at all. personally i believe passwd -l root is a superior answer to what pam trys to address. i agree with 1clue about sudo.
ive been playing with the idea of
1. powerless user with ssh keys to login as sudo user
2. sudo user with no password set.
3. sudo su to get to root which also has no password login options.
or powerless user with keys to root user.
auth required pam_tally2.so deny=3 unlock_time=30 even_deny_root
added to /etc/pam.d/system-auth for my experiments.
idk, jailing ssh with fail2ban might be something for you to investigate. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
mv Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
![](images/avatars/169262237648b51b40d0ec0.png)
Joined: 20 Apr 2005 Posts: 6780
|
Posted: Tue Mar 04, 2014 8:27 pm Post subject: |
|
|
1clue wrote: | Hu wrote: | As already stated above, sudo is not enough in some cases. I know of no way to allow privileged rsync using sudo to elevate the remote side. |
I'm not convinced that a wrapper script on the remote end couldn't handle that. |
If you really know how to do this "cleanly" (without hacking your version of rsync or something similar), I would be interested to know: AFAIK, rsync just executes rsync over ssh with some magic parameters on the remote host. Of course, you could put a "fake" rsync into the path which somehow checks whether it is called remotely and then executes the "original" rsync eiither plainly or via sudo, but this is a rather nasty hack (requiring e.g. that this user can execute sudo for rsync without being asked for a password) so that I have some doubts that this is more secure than if you login "cleanly" as root. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
1clue Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Wed Mar 05, 2014 1:44 am Post subject: |
|
|
mv wrote: | 1clue wrote: | Hu wrote: | As already stated above, sudo is not enough in some cases. I know of no way to allow privileged rsync using sudo to elevate the remote side. |
I'm not convinced that a wrapper script on the remote end couldn't handle that. |
If you really know how to do this "cleanly" (without hacking your version of rsync or something similar), I would be interested to know: AFAIK, rsync just executes rsync over ssh with some magic parameters on the remote host. Of course, you could put a "fake" rsync into the path which somehow checks whether it is called remotely and then executes the "original" rsync eiither plainly or via sudo, but this is a rather nasty hack (requiring e.g. that this user can execute sudo for rsync without being asked for a password) so that I have some doubts that this is more secure than if you login "cleanly" as root. |
What's your objective? Are you just syncing two systems? Without knowing the project, I can't help much.
My main argument is that syncing an entire system isn't really all that great an idea. I have ALWAYS found a way to avoid it, meaning that I haven't ever actually done a full system transfer. You're sending security information and everything over the wire.
If you want to rsync system A's entire contents to system B, then start it from A as root, write it to system B as an unprivileged user into an excluded directory on B which does not exist on A. Then as root on B, sync from that to system B in its original location. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
BitJam Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 12 Aug 2003 Posts: 2513 Location: Silver City, NM
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
grant123 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 23 Mar 2005 Posts: 1099
|
Posted: Wed Mar 05, 2014 11:03 pm Post subject: |
|
|
1clue wrote: | You're sending security information and everything over the wire. |
But rsync encrypts via ssh, right?
1clue wrote: | If you want to rsync system A's entire contents to system B, then start it from A as root, write it to system B as an unprivileged user into an excluded directory on B which does not exist on A. Then as root on B, sync from that to system B in its original location. |
How can you write permissions/ownership info correctly as an unprivileged user? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
1clue Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Thu Mar 06, 2014 2:26 am Post subject: |
|
|
grant123 wrote: | 1clue wrote: | You're sending security information and everything over the wire. |
But rsync encrypts via ssh, right?
1clue wrote: | If you want to rsync system A's entire contents to system B, then start it from A as root, write it to system B as an unprivileged user into an excluded directory on B which does not exist on A. Then as root on B, sync from that to system B in its original location. |
How can you write permissions/ownership info correctly as an unprivileged user? |
By going here: https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Automated_Backup#Backup_with_rsync_and_sudo |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|