SSH configuration: chown username:group: says invalid user
There are a few things to take into consideration and I hope I'll cover some holes in your question.
First, when you use chown
, the user and group you're trying to assign the entities to should exist. If it doesn't, then you'll get an error. So make sure it does exist first.
Second, to use chown
, you need some elevated powers. You can't just move ownership of files, etc, to another user as a regular user yourself. Make sure you know what this means and that that's what you want.
Third, make sure you understand what you're trying to do. chown
changes the ownership of a filesystem entity or entities to the user and group you tell it.
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
My Ubuntu16.04.4 server has username: graycodes
THE ERROR OUTPUT:
chown: invalid user: 'vagrant:vagrant'
I'm setting file permissions for OpenSSH. What I'd like is to keep my username as graycodes and define the permisions using this username in place of the username vagrant.
chown -R vagrant:vagrant .ssh
I understand it reads as:
chown -R username:group file name
I've also tried firstly:
chown -R graycodes:vagrant .ssh
but it's not working. Do I have no choice but to make my server username as vagrant?
I believe this may work to add 'graycodes' to the group 'vagrant'.
$ groups $ sudo usermod -a -G vagrant $USER $ exec su -l $USER $ groups
-
Admin almost 6 yearsThen I believe I would need to add my user 'graycodes' to the group 'vagrant' which would give it permission in Vagrant. I figure the relevant commands could look like I've show in my edited question.
-
Admin almost 6 years@Gray It's still not clear to me what in fact you are trying to achieve.
-
Admin almost 6 yearsokay. I'm actually following the sitepoint base-box tutorial. I'm packaging a base box which I'll later provision an a LAMP server and then add wordpress to that. Here's the link to the sitepoint tutorial: sitepoint.com/create-share-vagrant-base-box (under subheading 'SSH configuration'..."Open SSH is very strict about this folder and file permission. So let's change it to the correct one.")
-
Admin almost 6 years@Gray That tutorial goes pretty much against my intuition and experience with Vagrant. My experience is distant, but I thought Vagrant is for fast and easy creation of virtual machines, while the tutorial makes this manual. Why use Vagrant then? Quite likely I'm not in the story. So abstracting from this, there's no step included in the tutorial where you'd install Vagrant itself. This plus the "invalid user" error makes me think you still miss the actual
vagrant
on your system. Am I wrong? -
Admin almost 6 yearsshift, I dnk what I'm doing. But I know how to do it one way. The way the tutorial says I should. But that means my username on the server HAS TO BE 'vagrant'.
-
Admin almost 6 years@Gray If you need to stick strictly to the tutorial, then stick to the
vagrant
username. This will make it easy for you. Anyhows, you'll have to install the actualvagrant
. And not just before you use it in a later command in the tutorial, because it's the installation process that creates the user and groups named "vagrant". You're banging your head against this wall already. The solution is this:sudo apt update; sudo apt install vagrant
.