SSH configuration: chown username:group: says invalid user

17,090

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.

Share:
17,090

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    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
    Admin almost 6 years
    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.
  • Admin
    Admin almost 6 years
    @Gray It's still not clear to me what in fact you are trying to achieve.
  • Admin
    Admin almost 6 years
    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.")
  • Admin
    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
    Admin almost 6 years
    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'.
  • Admin
    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 actual vagrant. 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.