My Ubuntu16.04.4 server has username: graycodes


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 

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.

  • Then 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. – user301042 Sep 19 '18 at 18:09
  • 2
    @Gray It's still not clear to me what in fact you are trying to achieve. – user147505 Sep 19 '18 at 18:10
  • okay. 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.") – user301042 Sep 19 '18 at 18:16
  • @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? – user147505 Sep 19 '18 at 18:29
  • shift, 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'. – user301042 Sep 19 '18 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy