Server

Scripting public-key-access-only user creation in Linux

The process of adding many users to a new Linux system can get tedious, especially if it is involved. So, let's replace the process with a simple shell script.

For this example, public keys are the only allowed login method. Password login is disabled, so the password is not set. The first step is to run set -e to stop the script on any errors. Next assign readable variable names, and check they aren't null. Next the user is created, and as the user the public keys are setup.

Subscribe to Server