Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to create user without password like this:

sudo adduser \
   --system \
   --shell /bin/bash \
   --gecos ‘User for managing of git version control’ \
   --group \
   --disabled-password \
   --home /home/git \
   git

It's created fine. But when I try to login under the git user I'm getting the password entering:

su git
Password:...

When I leave it empty I get an error:

su: Authentication failed

What's wrong?

share|improve this question
    
Nothing is wrong, the authentication failed as expected. You won't get a "there is no password, you can't login" error message. –  scai Nov 26 '12 at 13:43
    
But I need to create .ssh folder under the git user, how should I do that? –  Erik Nov 26 '12 at 13:46
    
Either create it as root and set the correct permissions, or execute su git as root where you don't have to provide a password. –  scai Nov 26 '12 at 13:46
    
How should I set the correct permissions? –  Erik Nov 26 '12 at 13:50
1  
By using chmod and chown. You should start to learn at least some basic commands. –  scai Nov 26 '12 at 13:52
show 2 more comments

2 Answers

up vote 3 down vote accepted

You've created a user with a “disabled password”, meaning that there is no password that will let you log in as this used. This is different from creating a user that anyone can log in as without supplying a password, which is achieved by specifying an empty password and is very rarely useful.

In order to execute commands as such “system” users who don't log in normally, you need to hop via the root account:

su -c 'su git -c "git init"'

or

sudo -u git git init

If you want certain users to be able to run commands as the git user without letting them run commands as root, set up sudo (run visudo as root and add a line like %gitters ALL = (git) ALL).

share|improve this answer
    
Thanks for the help! –  Erik Nov 27 '12 at 5:51
add comment

If you want to access the system under the git user you should use sudo:

sudo -s -u git

or

sudo su - git
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.