To create a new user, first we need to login as a superuser into the server. Afterwards we can add a new user using useradd.
sudo useradd --create-home -s /bin/bash deploy_user
Now let’s set the password for the new user.
sudo passwd deploy_user
After changing the password, we will enable the new user to connect to the server. In case you just need a new user for owning files, running server or any kind of tasks, that does not need a remote login, you can skip the next step. Instead you can use su to change the active user.
su -l deploy_user
Enable ssh access
sudo vi /etc/ssh/sshd_config
Please check if you already have the AllowUsers directive inside. If this is the case, just add the deploy_user to the end of it. Otherwise the entire directive. Either way, you should end up with something like this
AllowUsers user1 user2 deploy_user
Please be aware! In case you added this directive, make sure that you include at least 1 super user. Otherwise you won’t be able to connect to your server again.
Now you can access the server using your new (deployment) user.