Sometimes we need to create another user on remote server. And add custom priveleges to it. Let's make it on Ubuntu machine. I assume we have root access to the server.
Lets login as root
ssh root@<my-server-ip>
Later create user
adduser my-temporary-user
To check all users on Ubuntu machine run
cut -d: -f1 /etc/passwd
List of the users will be very long...
But when we want to list only numan we should run
awk -F: '$3 >= 1000 { print $1 }' /etc/passwd
First we need to login as our new user from the root
su - my-temporary-user
Probably new user will not have ssh folder so we need to create it and add permissions
mkdir -p ~/.ssh
chmod 700 ~/.ssh
Than, generate key pair for this user
ssh-keygen -t ed25519 -C "my-temporary-user" ## message can be any but I named the same as user to make it more understandable
ls -l
##output
my-temporary-user
my-temporary-user.pub
Add the key to the authorized keys
cat ~/.ssh/my-temporary-user.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Copy the key to the local computer. In my case to the desktop, because later I wil transfer that to another local machine
scp root@<my-server-ip>:/home/my-temporary-user/.ssh/my_temporary_user ~/Desktop/my_temporary_user
Then, copy from my local machine Desktop to the ssh keys of my local server
scp ~/Desktop/my_temporary_user username@<ip-local-server>:.ssh/my_temporary_user
## apply permisions from the local machine
chmod 600 ~/.ssh/my_temporary_user