OpenSSH user enumeration
openwall.com
openwall.com
But on the subject of passwords, best practice for SSH for a long time has been to disable password based login entirely and rely on keys.
For instance, an OpenBSD box running Tor may have a user "_tor", a Debian-based box (e.g. Ubuntu) may have a user "debian-tor", and so on (depending on how Tor was installed, in my case via pkg_add & apt-get; usernames might vary for different OS/repo versions). I have tested this using the PoC against some of my own systems (the ones that have PasswordAuthentication still enabled) and it works for those.
Shodan shows some 66k services identifying as SSH-2.0-dropbear [2], as opposed to some 15k identifying as SSH-2.0-OpenSSH [3].
Issue has been reported to the vendor today.
[0] https://www.reddit.com/r/blackhat/comments/97ywnm/openssh_us...
[1] https://github.com/mkj/dropbear/blob/master/svr-auth.c#L175-...
Does a system appear to run one of the many horribly insecure "enterprise" backup solutions? Or some other horrible, ancient system?
Does $person from orgchart appear to have a $user? (target for spear phising, compromise of laptop).
Information hinting at distribution (eg: Ubuntu).
Is there a jboss user? Etc.
PasswordAuthentication no sudo apt install tinyssh
wget https://github.com/yourusername.keys -O ~/.ssh/authorized_keys
sudo systemctl enable tinysshd.socket
but it's not widely used, which makes using it risky. To my knowledge there hasn't been a formal audit. Also it doesn't implement the scp protocol, but you can use rscync over ssh alias scp="rsync -e ssh --progress"From the FAQ[1]:
> TinySSH doesn’t have problem with scp protocol, only doesn’t have scp program.
I assume this means an OpenSSH `scp` command will work just fine when pointed at a tinyssh daemon, without the rsync alias.
Immediate pro: Public domain / CC0
Immediate potential-con: Doesn't implement compression
ChallengeResponseAuthentication no openssh (1:4.1p1-1) experimental; urgency=low
[…]
* Disable ChallengeResponseAuthentication in new installations, returning
to PasswordAuthentication by default, since it now supports PAM and
apparently works better with a non-threaded sshd (closes: #247521).
[…]
-- Colin Watson <cjwatson@debian.org> Tue, 31 May 2005 01:33:33 +0100
https://bugs.debian.org/247521Though, if you're using TOTP via a PAM module, you'll want it
I suppose even minimal extra security would've helped (no root user, only allow x login attempts in y time, changing the port for ssh), but I was still surprised someone got in so soon by simply guessing a 20+ string of gibberish (I still wonder if maybe something else happened).
All that said, I've had servers running for years without any successful hack, and in all those cases using ssh keys instead of password logins probably made all the difference.
The only alternative that I can think of is that one of the two other users' machines was compromised, but AFAIK I didn't give them root access. Plus, the logs show an extreme number of login attempts (tens of thousands of entries in auth.log) with an eventually successful root login.
Any other ideas of what might've been an alternative cause?
Maybe you’re right though.
EDIT: to be clear, I am pretty sure was the only person who used the root password to log in, and the single other user used a similarly long and random password with a different username. if I'd been compromised my problems would be quite a bit bigger. All I know is that right before the 'fatal' root login, there are 40.000+ lines of login attempts from ip's that originated from shady places (at least based on entering them in various GeoIP sites).
Just to be sure: PasswordAuthentication does not need to be enabled for the PoC to work, and username testing can also be used for software enumeration by testing for common/default non-SSH users, .g. "_tor", "debian-tor", etc. (I apologize for repeating here what I also stated in other comments in this thread, but this aspect should not be overlooked.)
If somebody hacked into my password manager and managed to steal the root user's password then they could do the same with my private key. Where is the difference?
Also, if somebody hacked into a non-root administrative account, they can just use sudo to elevate. What makes disabling root login more secure?
Keys can be leaked but since it involves copying files and users aren’t penalized for using strong ones it’s much less common.
2. When using real password authentication, connecting to a compromised server results in a disclosure of your password. When using challenge-response authentication, it does not. Note that correctly-configured OpenSSH uses challenge-response even for password-based methods. Incorrectly configured SSH will send passwords over the wire.
What do you mean?
With real password when you type your password into the ssh password prompt it then sends that password to the server.
Challenge response is a method in which you usually encrypt or hash random server provided data. You send the hash. The server knows your password and can hash the data with it too. The hashes are compared not the password. In this method the password never leaves your machine. Replay attacks are prevented due to the server sending different data for you to hash on different login attempts.
http://www.securiteam.com/securitynews/5KP0O0A3PU.html
Does anyone know of recent work on passively attacking interactive ssh in order to guess what's being typed? I could see machine learning helping here, given the ability to observe enough sessions to form a training set...
Point being - it needs to be managed like a key: it's inconvenient to type, hard to remember, should be stored encrypted at rest, preferably in an hsm.
Gnupg agent/ssh agent and the various key agents for desktops all do this, and generally support hsm as well.
There's also a small difference in the complexity of enumerating the keyspace of rsa/ed2259 vs trying random passwords. With key stretching I'm not sure if there's implicit differences in rate of attempting login.
As for no direct root login via ssh - I think it depends a bit on the server. On a shared system login via regular user +sudo leaves an easier audit trail (who ran "sudo apt-get dist-upgrade" on Friday evening and took the weekend off without checking that production systems didn't crash... Was it "root" or "bob "?).
Then there's the nudge towards only doing what needs root as root (eg: curl/wget stuff as regular user, verify signatures, content - then run as root).
Is it more secure to locally dump and asymmetrically encrypt backups on disk as root - locally, and have a dedicated backup-user that gets the archives? Probably.
In general ssh keys (and certs more so) makes it feasible to split up access and authorization, revoke access etc without relying on something complex like ldap/kerberos for user management.
> Also, if somebody hacked into a non-root administrative account, they can just use sudo to elevate.
If they only have your ssh key, they'd typically need your password to elevate. Or you might require a shared root password - or set a password on wheel and require newgrp wheel before sudo. Not sure if the latter with disabled root account has much benefit, though.
Might also reveal the purpose of the machine (oh, this is probably the build server) or who is managing it.
It is information leakage, not the end of the world but it can potentially be helpful for an attacker.
- root
- user
- ansible_conf_daemon_user
End of List. It's all containers so IDGAF and I use pubkey authentication on each user.
Running all software under the same uid is also usually best avoided, you'll always have data at rest somewhere (which needs to be backed up, access controlled, and so on).
Additionally most of those are containers where running it all as the same UID isn't a problem.
Containerization isn't really relevant to protecting data, as you'd normally find data volumes and backups attached.
Plus, this is LXC, not Docker. There is no data volumes or backups attached. Backups are shipped to an append only server via SSH tunnel with low privileges, which also doesn't have nonstandard users setup.
Subject: Include the Debian version in our identification
This makes it easier to audit networks for versions patched against security vulnerabilities. It has little detrimental effect, as attackers will generally just try attacks rather than bothering to scan for vulnerable-looking version strings. (However, see debian-banner.patch.)
If you strictly use public key authentication and don’t expose your SSH server to the public internet, this is a non-issue. Furthermore there’s no defensible reason not to do that - it’s very straightforward to firewall SSH access behind a private network, and VPNs exist precisely for this reason. Access to the network and access to machines within the network should be strictly decomposed. If you allow SSH access from the public internet and have a VPN, you have to worry about two (privileged) points of failure, not one. Put everything behind a public-key authenticated VPN and SSH vulnerabilities are obviated, with the exception of insider threats in the organization.
ChallengeResponseAuthentication no # \
PasswordAuthentication no # | nukes "Password: "
UsePAM no # /
PermitRootLogin no # (duh)
PubkeyAuthentication yes # enables public keys; very important
AllowUsers user1 user2 # maybe? combine with an obscure username...Incidentally I only ever used it at home, on a LAN that only has devices I know about on it. In a work environment I'd only ever do the same running off an isolated lab switch.
But in certain situations, "login to the box as root w/ no pw" is awesome for rapid bringup/diagnosis/repair/whatever.
a) Why are you using bleeding edge software in production, and especially so unreleased versions of OpenSSH?
b) Why are your SSH servers exposed to public traffic?
c) User enumeration is useful for finding accounts with weak passwords. Why do you have personal accounts on prod servers? Why do you have _any_ accounts not using public key authentication at all?
> We believe that this issue warrants a CVE; it affects all operating systems, all OpenSSH versions (we went back as far as OpenSSH 2.3.0, released in November 2000), and is easier to exploit than previous OpenSSH username enumerations...
As for b) and c), I 100% agree.
In fact: if you're using KVM-based virtualization, and you have VNC or serial access to your node (GCP gives you serial access, via web UI or an SSH-based proxy), you could completely _disable_ standard network-based login. (Writing an admin tool that connects to the serial console, gets a usable shell, and enables your sshd for when you need it, is an exercise for the inspired sysadmin. :P)
But this fun little trick is going to break a lot of stuff.
Perhaps a valuable resource would have a disposable proxy in front of it; then one way in (or even no ways in!) might be viable.
c) Not only production servers utilize internet.
c) fair enough, although you should probably be using keypairs and a vpn for test and dev envs too.
Other commenters have mentioned this attack getting information on hosted services on the system. But, usually you can get that from a straightforward nmap or other recon tool anyway.
In SSH first every connection is encrypted (before either side knows who the other is, encryption is used already, this is the same approach taken in TLS 1.3), then the server has to authenticate to the client, and then the client authenticates to the server on behalf of a specific user.
User public key authentication is a multi-phase protocol. This would be too awkward for something like HTTP where round trip times may be appalling, but SSH is rarely used at long distances.
In phase 1 the client proposes that it can authenticate for some public key Pn, it sends this proposal to the server, and the server can either say OK, go ahead, or reject this authentication without seeing it done, on the basis that it doesn't trust Pn anyway. It can keep trying different Pn until either it runs out or the server grows tired of this nonsense and disconnects it.
Once it has an OK, in phase 2 the client signs a nonce with the private key corresponding to Pn, which the server can now verify. If the signature checks out, the authentication was successful.
This means an adversary who knows your SSH username but has nothing else would need to literally _guess_ your hypothetical 1024-bit RSA key, not just (already hard but plausibly within the grasp of a resourceful adversary) break a 1024-bit RSA public key to find the associated private key, as your client only tells authenticated servers even the _public_ key.
Aside: One thing I'm surprised I haven't seen done with this part of the SSH design is user TOFU [Trust On First Use]. Lots of home or small / non-security business SSH setups do TOFU for server authentication, sometimes with a fig leaf ("Ask Jerry in IT to tell you the SSH keys" or "The SSH server keys are pasted into this Wiki page"). But I've never seen people do TOFU for the user authentication. In a similarly lax environment why not set up new users, and then when they first connnect just accept whichever public key they offer as "their" key, set that as trusted, and from then on insist on the same key for that user ? I feel like password auth is often left enabled because people are using it for an "initial" authentication step when first setting up without yet trusting any keys - and then never remove it. With "User TOFU" they'd have no incentive to enable password authentication at all.