I have a client that needs to connect to one of my machines through ssh (Debian stretch). When i create his account with the adduser command, he recieves a home directory but there are no subdirectories in it, such as Downloads, Documents ect...

adduser bob --disabled-password

This user is never going to login to the GUI for those to generate. How can i add these in when the account is created without the GUI?

Additionally, after i add his account. Is there a way to enforce him to change his password upon first login through SSH? ( he will be logging in with a ssh key)

Obviously i could mkdir each one, and forceably set his password as root after he tells me what he wants it to be but im looking for what the best practice is here.


Building on the suggested related answer, Why are folders in home directory (Documents, Pictures, etc) created only after the first graphical login?, you can run this command as root to pre-create the XDG directories for your user bob:

su - bob -c /usr/bin/xdg-user-dirs-update

In terms of best practice for passwords, that's a minefield. My particular thought is to generate a 12-16 character pseudo-random password that can be typed fairly easily and set that to expire on first use (passwd -e).

useradd -m -c 'Bob is my friend' -s /bin/bash bob
passwd bob    # Enter a suitable pseudo-random password for Bob
passwd -e bob

Consider, though, that if your user is going to be logging in with an ssh certificate/key then it may be that they never even need to know their password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.