32

I have a user without a password set (i.e. passwd -d).

I would not like to use public keys on this setup.

Is there a way to SSH login to such a user?

1
  • do you want to login as that user, or do you want to be sure that no one else logs in as that user?
    – Baarn
    Jan 29, 2012 at 17:45

4 Answers 4

26

PermitEmptyPasswords yes then restart sshd ?

4
  • 2
    This works, but is horribly insecure. Jan 31, 2012 at 12:31
  • 2
    For sure, but well, as said : I would not like to use public keys on this setup. Jan 31, 2012 at 16:43
  • 4
    With Ubuntu 13.10 PermitEmptyPasswords yes doesn't let the user with an empty password set login, even after a reboot.
    – Pro Backup
    Feb 12, 2014 at 6:42
  • 13
    @ProBackup you'll have to add ssh to /etc/securetty for this to work.
    – Ruslan
    Nov 29, 2017 at 19:16
3

Allow PermitEmptyPasswords in sshd_config and restart sshd.

0
2

If you just want to become the user in question, the simplest way is to log in as some other user (via ssh) and su $username. This requires root privilegies, but you could put the command in /etc/sudoers and only let your user execute that command as root.

If you really want to login through ssh (or remotely in some other way), you need to pick one of the following:

  • Let anyone anywhere (or at least on the network you're on) login.
  • Use a password to restrict who can login.
  • Use certificates to restrict who can login. For ssh directly, this means a public/private key pair, either the ssh-style rsa pair or x509 (like for other ssl stuff).
2
  • This is a little confused: 1) su is not sudo 2) with sudo the "as root" does not apply. While using su is an option, I (as a former Unix sysadmin) would rather see a focus on the use of sudo. Jan 31, 2012 at 11:07
  • 1
    I don't see what you mean. 1) sudo does not look like logging in as or switching to a user, su does. The op wanted to log in as some user, not execute commands as it. 2) sudo lets you execute commands as another user (see man sudo if you don't believe me). In this case you would like to execute su as root to avoid having to give a password for the user you switch into. 3) Different tools for different tasks, although I guess some people have higher tolerances than me for typing sudo -u postfix before their actual commands.
    – Eroen
    Jan 31, 2012 at 13:35
0

You need to do all of the following:

  • Set PermitRootLogin yes and PermitEmptyPasswords yes in /etc/ssh/sshd_config
  • Set StrictModes yes in /etc/ssh/sshd_config
  • Add ssh to /etc/securetty
  • service ssh restart
2
  • There's no reason to allow logging in as root using a password, as the OP did not say that they specifically wanted to be able to log in as root without a password.
    – 9pfs
    Aug 15, 2023 at 21:41
  • Yes @9pfs, I agree. But to login without a password, I figured you need allow login as root (PermitRootLogin yes) AND empty passwords (PermitEmptyPasswords yes).
    – Piffre
    Aug 17, 2023 at 7:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .