News for hackers. Stuff that matters.
Re:Hashing is not encryption by LinuxBender on Sunday January 09, 2022 @12:36PM (#29865456)
One mitigation against this is to specify on the target hosts where that keys are valid from. One could even be as liberal as to give the entire CIDR block of their ISP or Corporate IP CIDR block or preferably use a VPN network. The key will not be valid for anyone not in the specified networks or IP's separated by commas.

e.g. using my tinc VPN mesh

  grep keys /etc/ssh/sshd_config
  AuthorizedKeysFile          /etc/ssh/keys/%u
cat /etc/ssh/keys/root # honeypot server

  from="192.168.0.0/16,10.15.10.2" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDlyvd+LAveSiIIgQW3Y+aWsb8bTu70tgXQjoWMrMAbKt1/sDoE/w2qqLBSqLjJmA46zKqwgZhnO8hkZjpizjb909fNYrgyNOsRcHOvumanORUGjcumxi5fklqNZCXC1rehX4z+tnVzygtDNQcqlmyy1ElBM+SxKS+YIrOymPOU6bc5V1sildq5cVUSuEHcLggOadCj6azbiR1J46D6UYxAaKYjq2OloLZXRhvSYrmVeH+PNKiShgYBu4TfCg4UoJKZsHTaeS2akZAQTqcjy7bB8HRWGXYEMKAKA95w8MTqaWlIoMKBuOJnd8+wRXrZKnSsTQmQQZg0rggO6GC8ufT leaked_on_purpose
I would be happy to provide my private key and a VM IP if anyone would like to try this out.
Re:Hashing is not encryption by xyzzyz on Sunday January 09, 2022 @01:02PM (#29865739)
If you think this is secure even if you leak private key, why not just disable key checking altogether and just allow anyone to log in if they come from accepted network?
Re:Hashing is not encryption by Taek on Sunday January 09, 2022 @01:30PM (#29865978)
Defense in depth - have several independent layers of security so you have some breathing room to fix things if one of the layers is fully compromised.
Re:Hashing is not encryption by LinuxBender on Sunday January 09, 2022 @01:07PM (#29865777)
One could do that as well. Different use cases can mix and match any restrictions using the Match block in sshd_config or simply having a general restriction like this.

  AllowUsers [email protected].*.*
Re:Hashing is not encryption by DarylZero on Sunday January 09, 2022 @02:18PM (#29866426)
Does OpenSSH let you disable all authentication?
Re:Hashing is not encryption by LinuxBender on Sunday January 09, 2022 @02:22PM (#29866464)
Does OpenSSH let you disable all authentication?

Yes one can disable any/all forms of authentication. At that point it might be worth shutting down the SSH daemon to save a few MB of ram. If you mean permit null passwords that can be enabled too.

Re:Hashing is not encryption by DarylZero on Sunday January 09, 2022 @02:32PM (#29866561)
Huh. Neat.

> At that point it might be worth shutting down the SSH daemon

Could be useful with ForceCommand. Sometimes you really only want to authenticate the server -- like with HTTPS.

Re:Hashing is not encryption by LinuxBender on Sunday January 09, 2022 @02:36PM (#29866591)
Good point. That is what I am doing:

  Match Group                     sftpusers
    PubkeyAuthentication            yes
    PasswordAuthentication          yes
    PermitEmptyPasswords            yes
    GatewayPorts                    no
    ChrootDirectory                 /data/sftphome/%u
    ForceCommand                    internal-sftp -l DEBUG1 -f AUTHPRIV -P symlink,hardlink,fsync,rmdir,remove,rename,posix-rename
    AllowTcpForwarding              no
    AllowAgentForwarding            no
Re:Hashing is not encryption by DarylZero on Monday January 10, 2022 @10:05AM (#29875901)
You have `PubkeyAuthentication` and `PasswordAuthentication` both set to `yes`, which is confusing to me. I thought you were saying they were disabled.

When I connect without a `-i` parameter the SSH client attempts to authenticate with all my keys, succeeding with none, then succeeds with authentication type `none`. When I specify -i `/dev/null` the logs are confusing as to what's happening:

    $ ssh -i /dev/null -v [email protected] 2>&1 | egrep -ie 'auth|attempt'
    debug1: Authenticating to 50.116.13.30:22 as 'serveradmin'
    debug1: Will attempt key: /dev/null  explicit
    debug1: Authentication succeeded (none).
    Authenticated to 50.116.13.30 ([50.116.13.30]:22).
I guess what you actually did was not disable authentication methods, but enable empty passwords, and set the account to an empty password -- and SSH does not even ask for the empty password in this case or even call it the same name as password auth in the logs. I guess!?
Re:Hashing is not encryption by LinuxBender on Monday January 10, 2022 @10:37AM (#29876452)
Having both set to yes means you are able to use either. Earlier I mentioned there was the possibility to disable both of them at which point nobody would be able to log in because only keys and passwords are used on that system. That is why I jokingly said you may as well shut down the daemon to save ram. There are methods other than keys and passwords but I have not implemented any of them.

A null password is using none [1] which is a reserved term and has specific implications. In this case of passwords, none will succeed since I enabled null passwords and that account has no password set. So none is matching in the PasswordAuthentication option.

  /etc/passwd  serveradmin:x:22218:5000::/data/sftphome/serveradmin:/bin/false
  /etc/shadow  serveradmin::18955:0:99999:7:::
There is no password hash after the first colon in the shadow entry. This was accomplished with

  usermod -p '' serveradmin
Using -i pass a key file but since I have not added any of your keys to the system then any key you specify will not match and the client will proceed on to the next authentication method you have enabled and have not explicitly disabled in the client. To accept any random key would require a change to the source code of OpenSSH. One can even hard code a public key into OpenSSH in the source code which I have done when configuring OpenSSH as a recovery daemon that does not read or write to the disk.

I hope that helps this make sense. It is understandable that this is confusing because what I am doing is the opposite of what people are instructed to do. Null passwords are considered a security risk unless you do it intentionally for some unorthodox implementation reason which I have done. I have a cron job that adds accounts within some character restrictions that bots try to brute force. I then monitor the bots behavior to see what current bots are attempting over SSH. I do the same for http/https. Both are what is referred to as a low-interaction honeypot.

Here is a bot with IP and port redacted that just tried to use my server as a DNS proxy:

  Connection from 8.37.x.x port x on 50.116.13.30 port 22
  Accepted password for admin from 8.37.x.x port x ssh2
  Changed root directory to "/data/sftphome/admin" [postauth]
  refused local port forward: originator 127.0.0.1 port x,  target 1.1.1.1 port 53 [postauth]
  Received disconnect from 8.37.x.x port x:11: Disconnected on user's request. [postauth]
[1] - https://datatracker.ietf.org/doc/html/rfc4252#page-7