If you have ever worked with a Linux server before, then you probably know the pain of setting up a new SSH user(for those who doesn’t know what is ssh – it serves as an application to login to remote computers as users). It is not the most difficult thing in the world but doing it over and over again is not worth your time – and it’s boring!
So let’s do some bash magic ( or scripting) and make our life a bit easier.
Before diving into the setup, take a look at the useful features it can do for you :
- It will add a new user to the remote system.
- It will install sudo if it does not already exist.
- It will add the newly created user to the sudoers list.
- It sets up passwordless login for the new user.
- Optionally disables the root login from ssh configuration after setting up the new user (recommended).
Note: You need root access to the server for the script to work
Steps to setup new SSH User:
Follow the instructions given below step by step to ensure that you won’t skip any:
- Download the script from Github. You can find it in handy-scripts repository along with some other useful scripts or you can just grab the gist.
$ git clone https://github.com/nvnmo/handy-scripts<br></br>
- Execute the script
$ bash handy-scripts/Debian-Server-Setup/add-new-user-passwordless.sh
Then it will ask for your server’s IP or domain name, new username and password and the root password. Provide these credentials and sit back while it does the hard work for you.
Finally it will ask you whether you want to disable the root login. It is highly recommended as it is a good practice for securing your server.
That’s it! Now you can login to the remote system as the new user without being asked for the password.
Also read:SSH key configuration
Spread the word and help others if you found this post useful! 🙂
PS: Want to secure the new SSH user you’ve created? Then, Read: Securing your SSH server.
If you have any suggestions or questions, leave them down in the comment section.
Subscribe to Code Rewritten
Get the latest posts delivered right to your inbox