Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set random password #6

Open
basz opened this issue Feb 1, 2019 · 6 comments
Open

set random password #6

basz opened this issue Feb 1, 2019 · 6 comments

Comments

@basz
Copy link

basz commented Feb 1, 2019

Hello,

Would you consider adding a random password to the user creation 'cause otherwise the account is locked and passwordless keys will not work.

Try this role and then dev-sec.ssh-hardening. You will not be able to login at all.

- name: Create user
  user:
    generate_ssh_key: "{{ user_generate_ssh_key }}"
    groups: "{{ (user_groups | join(',')) }}"
    append: True
    name: "{{ user_name }}"
    shell: "{{ user_shell }}"
    # this generates a hashed and random uuid string
    password: "{{ 9999999999999999999999 | random | string | to_uuid | password_hash('sha512', 65534 | random | string) }}"
    update_password: on_create
@nickjj
Copy link
Owner

nickjj commented Feb 1, 2019

Hi,

I'm not sure what the dev-sec.ssh-hardening role does but if you supply your public SSH key to this role, you will be able to login to your server with your SSH key instead of needing a password.

Personally, I don't even allow password based logins to any of my servers and I'm surprised that the dev-sec SSH role would allow that by default.

@basz
Copy link
Author

basz commented Feb 2, 2019 via email

@nickjj
Copy link
Owner

nickjj commented Feb 2, 2019

This role copies your public SSH key to your server in the server's user's authorized_keys file. This is half of what allows you to login without having any sort of user password defined.

Then on the SSH side of things you can lock things down by setting:

PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes

Now you'll be able to login with only SSH keys that are allowed for a specific user.

@basz
Copy link
Author

basz commented Feb 2, 2019 via email

@basz
Copy link
Author

basz commented Feb 2, 2019

Scratch that last bit.

After setting the password correctly I can log in over ssh with pubkeys

sudo passwd zonderbaar

Concluding, an account needs a password set (on Debian 9?). I'll use a long random string for that...

@nickjj
Copy link
Owner

nickjj commented Feb 2, 2019

Something else resulted in you being locked out. Debian 9 has nothing in it that would block a user from signing in without a password.

You can test this on digitalocean very easily. Spin up a brand new Debian 9 server, and set your SSH key during droplet creation. When you do that, DO won't set a root password but you'll be able to SSH into your droplet with your SSH key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants