Step2: Setup Authentication on Remote - SwagatoMondal/Online-Shopping GitHub Wiki
You might have already logged in to your remote machine using being root
, but you might prefer to limit access to user / user-groups.
NOTE
The root user has unlimited permission and can execute any command. Hence it's a best practice to add a user with limited privileges to execute commands.
You can still run admin commands using sudo
.
- In order to add user use the following command -
adduser <user-name>
- You'll be prompted for new password, so set one here and press enter -
Enter new UNIX password:
- You'll be asked to enter more details like Full Name, Room Number, Work Phone, etc. This is an optional step and can be skipped.
- You want this user to now run root commands, hence you need to add this user to
sudo
group. In order to do this use this command -
adduser <user-name> sudo
- Now let's try to login using the user we just added. Now run command
exit
to come back to your local machine. - Now run the following command (Note instead of root we're using the new user-name) -
ssh <user-name>@<IP-address>
- You'll be prompted for password, enter the password you just set for this user.
You can check the CLI showing the following -
<user-name>@<hostname>:~$