Good day,
I have run into a problem setting up a new LAMP installation i setup on a droplet. (Keep in mind in am using the digital ocean console)
I am doing this tutorial specifically, and i am stuck on step four. I stopped at the instruction below because copy and paste don’t work on the console.
***Now open a file in .ssh called authorized_keys with a text editor. We will use nano to edit the file:
nano ~/.ssh/authorized_keys
Now insert your public key (which should be in your clipboard) by pasting it into the editor.
Hit CTRL-x to exit the file, then y to save the changes that you made, then ENTER to confirm the file name.***
What i did instead was login with filezilla using sftp and downloaded the key. i went in to the folder that i had created in console (/home/seyi/.ssh) and then dropped the text file i created in the folder. (i wasn’t sure if the file was supposed to be in .txt. or .pub so i put them both in the folder)
There was no way to know if it worked so i went back to console and did;
$ chmod 600 ~/.ssh/authorized_keys
That pulled an error: chmod: cannot access '/home/seyi/.ssh/authorized keys : No such file or directory.
Later i came back and tried $sudo apt-get update
entered the password and the got the error below “seyi is not in the sudoers file. the incident will be reported.”
…Help :(
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
@oasysweb
Instead of the DigitalOcean web-based console, I would recommend using PuTTy on Windows and Terminal or Hyper on MacOS so that you have copy/paste available. It’ll definitely ease the process since the vast majority of what you do through the CLI will require it at some point unless you simply like typing everything out by hand :-).
That said, when you’re running:
The
~
signifiesroot
orhome
when it comes to directories. If you’re logged in as theroot
user, then the above is actually opening this file:So the command is the same as:
The only time the
~
will apply to your user,seyi
, is when you are logged in to SSH as that user. It will then create a file relative to that users home directory.…
So let’s run through the steps from the start and hopefully that’ll help you get this resolved.
What I like to do is first create the users
home
directory as well as their.ssh
directory. We can do this in one shot by using:Once we have the home directory, we can now create our user and set their home directory using:
Now if you want this user to be a
sudo
user, you can add them to thesudo
group using:The above appends the user to the
sudo
group so that we’re not changing the main group (i.e the groupseyi
still exists and can be used).Now, to generate an SSH key pair for the user
seyi
we cancd
in to the.ssh
directory we created:and run:
When prompted for a location, simply enter in
/home/seyi/.ssh
and give the key a name. For example you could use:It’ll then output
seyi
andseyi.pub
in/home/seyi/.ssh
, so you should have:Now we’ll use
cat
to echo the contents ofseyi.pub
in toauthorized_keys
. This file doesn’t exist yet, but it will be automatically created for us using this command:Now we need to setup proper permissions on our files and directories using the user
seyi
and the groupseyi
.Now you should login and download:
and then remove them from the directory using:
You’ll use the
seyi
file as your private key file. Keep this file safe. If you lose it, you’ll have to repeat the above all over.That being said, you won’t be able to login using SFTP with this user just yet as changes need to be made to
/etc/ssh/sshd_config
first.First:
Find:
Comment it out so that it looks like:
And below it add:
Now find:
and below it add:
Exit and save. Now we’ll create a new group called
sftpusers
:and then add
seyi
to that group as well:Then restart SSH:
Now, even though you’re using SSH Keys to login, you’ll still need a password to use
sudo
, so we need to set a password onseyi
:At this point, using the private key file, you should be able to login to SFTP as
seyi
and when you login to SSH, that user will now be a sudo user as well, so commands such as:will prompt you for a password and then execute.