10 ms·
/bin/false is not security (2005)
- isostatic 9y agoModern ssh implementations won't let a user with a shell that isn't in /etc/shells access via ssh. Clearly you'll only be accepting public key authentication too.
- pecg 9y agoDisable root authentication over ssh should be the default too. This is literally ssh 101.
- jstimpfle 9y agowhat's wrong with public key auth as root? The "alternative" would be making a sudo-enabled login account. Another indirection, and probably not fully transparent...
- drdaeman 9y agoIn my personal opinion, there's nothing wrong with that, as long as key is not compromised, of course. However, it's somewhat less secure than sudo-enabled account with password requirement. If your SSH key is somehow compromised (unpassworded keyfile or attacker had gained access to ssh-agent's socket, or you've ran a network-listening daemon from your account that had an exploitable RCE) you're a little bit more safe if attackers won't get root access. This only works well for noexec $HOME, of course, as attacker can't mess with your .*shrc and trick you into entering the password.
- Spooky23 9y agoUse of shared accounts eliminates individual accountability if humans are using them. Unless you have an system with its own auth and audit capability connecting as root, shared accountability is bad. People do dumb shit, including illegal shit.
- isostatic 9y agoIf you have more than one person logging in, it's far easier to identify who did something as root by looking at the username that logged in. Also far better to encourage running sudo for every command, gives a nice simple audit log of what happened, right there in your syslog, so you can identify and undo mistakes, and also eliminate lines of enquiry. Clearly you can cover your tracks with the old sudo vi / !bash and similar tricks, but the goal isn't to protect against hostile privileges users, its to know what happened so that when John is on holiday you can see what he did to fix the problem you had last week.
- cuckcuckspruce 9y agoIf your sudoers policy allows you to run vi then you've already failed. sudoedit(8) has been around for a long time and it solves this problem.
- isostatic 9y agoFailed at what? I want my sysadmins to have full access, I just want to know what they did. I'm not trying to defend against malicious staff members - I trust them, otherwise they wouldn't have sudo access.
- cuckcuckspruce 9y agoIf you can trust your administrators then you don't need to worry about shell escapes in editors. The idea for sudoedit is that it allows you to allow non-root users to safely edit files, and if they shell out of their editor then they've not gained root rights - they edit a temporary file as a regular user and then sudo moves the file into place after it is edited.
- xstartup 9y agoIf you run any command it will run with the root privilege when you are root. It happened to me many times, where I ran a command and it asked for root then I investigated why the particular command needs root and figured that this is not what I want in the first place. So, account with sudo capabilities is better than then one which is sudo by default.
- merb 9y agoit's not more secure/less secure if you enable root over pubkey only. I mean if I can login with a user that has sudo rights (probably with no password, the default on most cloud providers) there is no real benefit in having a user called ubuntu or centos that can login and gain full sudo rights than using root directly.
- pecg 9y agoIf the password used for the user, in the remote machine, is different from that of the machine he/she is connecting from, the attacker will not be able to gain root access, even if the account has permission to escalate priviledges.
- inetknght 9y agoI don't see how the authentication used for a user on a local machine has anything to do with the authentication of a user on a remote machine unless both are using the same domain authentication (RADIUS, Active Directory, etc). Even then, there can be cache involved.
- closeparen 9y agoThere could be a local compromise that exposes the SSH keys (for login) but not the remote password (for sudo).
- inetknght 9y agoMy parent comment indicates that the password needs to be different. Your comment does not support that. First, sudo should not be cached for this very reason. Second, agent caching should never be enabled for this very reason. Third, agent forwarding should never be enabled for this very reason. Indeed, using key authentication to log in and then using a password to upgrade to sudo is, I think, very reasonable.
- merb 9y ago
- fiddlerwoaroof 9y agoI don’t really see the benefit of disabling root logon vs. allowing user login + sudo to root, if you only allow login via keypairs. This seems to me to be one of those cases where there might be some theoretical benefits, but those benefits don’t matter in practice. Edit: I see several other people posted this while I was typing :)
- emsy 9y agoI configured it so I can only sudo with my password. So even if someone gets hold of my private key, they'd have to guess my password for sudo access. Also, as someone pointed out you can restrict sudo commands, which is the sensible thing to do.
- icebraining 9y agothey'd have to guess my password for sudo access. SSH to your account, add an alias to sudo in .bashrc (or equivalent for your shell) that records the password in a hidden file before passing it to the real sudo.
- zrth 9y agoIs there a practical way to prevent this kind of attack? Also, what the name for this class of exploitation so I can read more?
- daimrod 9y agoUse the absolute path to any */sbin utilities :-)
- jwilk 9y agoDoesn't help much. Once the attacker took over the account, nothing you do or see can be assumed to be real. For example, the attacker could inject a LD_PRELOAD library that redirects execve() calls from /usr/bin/sudo to a fake version of sudo.
- mkj 9y agoBack in 2005 it was standard for SSH servers to check /etc/shells. Maybe the RIT admins had put /bin/false in /etc/shells for some reason.
- tinus_hn 9y agoThis article is completely irrelevant and outdated. The only reason this works on Solaris because it is so ancient it predates the /etc/shells system.
- craftyguy 9y agothe article it from 2005, you're not wrong.
- pecg 9y agoSimple and straightforward article that exposes one of many usual misbehaviors of so called sysadmins these days: they think they know their tools, but haven't even completely read the manual for the programs they rely on production environments. Systems administration is something to be taken seriously; recently a friend of mine, that knows nothing about network perimeter security and didn't enforced adequate credentials on production environments, got a RANSOMWARE on a machine with a critical for business instance of a CRM database, chiefs on the organization refused to pay for the bitcoins asked, and probably my friend will be fired for incompetence; the infrastructure department personnel doesn't even have backups of such server, it's clear the information is lost forever.
- empath75 9y agoNobody has time to read the manuals for everything, come on.
- eesmith 9y ago"These days"? What you describe has happened for decades, though of course with different details. You never knew about sys admins who put "." in the PATH for root? That was one of the warnings that I remember learning back in the early 1990s. Remember the good old days when someone's .finger could be used for an escape sequence injection? Even if you read the manual for your terminal, that doesn't mean you change all your habits. Or sys admins using "xhost +" for easy access to other machines in the local network? And sys admins forgetting to do backups? That's certainly nothing new.
- icedchai 9y agoEarly SGI systems, maybe as late as IRIX 5.x, actually shipped with "xhost +" as the default! I remember people putting these on the internet with no firewall (of course... this was the mid 90's) not realizing they could be key logged remotely...
- eesmith 9y agoI had a IRIX 5.x box and I remember having to do "xhost +". Which I did, because ... easy.
- STRML 9y agoFWIW, I tried that DoS idea on a little digitalocean machine. It capped the number of open file descriptors for the SSH daemon at 1024. Only about 3000 file descriptors were in use after it stopped allocating channels, and file-heavy operations like apt-get still succeeded.
- deleted 9y ago[deleted]
- bvinc 9y agoYou'll probably hit the ulimit maximum file descriptors for the process. This might cause problems for the sshd process, or it might not since it might just hit the maximum for a process that's dedicated to your ssh connection. It would take a lot more processes to hit the maximum for the entire system
- aexaey 9y agofail2ban [1] would take care of this by automatically firewalling off IPs that fail to authenticate too frequently. [1] https://www.fail2ban.org/ https://www.fail2ban.org/
- lvh 9y agoWould it? My understanding is the authentication worked just fine, it’s just spawning a shell that doesn’t. That could be intentional: eg for SFTP hosts or jump hosts.
- bch 9y agoI recall reading of one Unix implementation that when executing /bin/false noticed that the spawned shell (/bin/false) had failed (because that’s what /bin/false does, by design) and helpfully launched /bin/sh so you could debug it. True or false (pun intended), this is why I use /bin/true to stand in as a shell in this capacity.
- 0xmohit 9y agoSSH best priactices [0] says: - Use public key authentication - Encrypt your private keys - Check the Host keys - Use SSH Agent - Use a different key for every computer - Disable password authentication - Do not SSH cross-server - Use safe algorithms - Use agent forwarding at appropriate times - Use SSH certificates - Use a smartcard - Remove all system passwords - Use Two-factor Authentication [0] https://blog.0xbadc0de.be/archives/300 https://blog.0xbadc0de.be/archives/300