Note that you can use this method with any account, there is no explicit need for a new user.
Creating a new user within Ubuntu is very straightforward. Type the following command.
adduser username
The above command created a fully functional user titled username.
In Ubuntu, each user has a .ssh
directory within their home directory. We will be copying the SSH key from the root user’s SSH directory to the new user’s directory.
More than likely, the .ssh
directory doesn’t exist, let’s go ahead and create that directory.
sudo mkdir /home/username/.ssh
Now we can copy the SSH key files from root to username.
sudo cp -rf /root/.ssh/* /home/username/.ssh/
Before we can use the SSH key, we must make sure we change the user rights to username.
chown -R username:username /home/username/.ssh
Congratulations! If you followed the above commands correctly, you will now be able to login to username with your SSH key.
]]>