Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok here's the deal - im new to SSH and have been googling around trying to figure this out. Objective for me has been to create a FTP user that can login only to: /var/www/ - however what I experience is that the user I create gets logged into /home/username and that I can actually browse all other folders on the server with this user.

These are the steps ive done - am I missing anything specific?

1. mkdir /var/www/
2. mkdir /var/www/
3. useradd <-username>
4. passwrd <-username>
5. chown –R <-username> /var/www/
5. groupadd <-groupname>
6. gpasswd -a <-username> <-groupname>
7. chgrp -R <-groupname> /var/www/
8. chmod -R g+rw /var/www/

Done on a Centos / linux installation.

share|improve this question
What FTP server are you using? – DerfK Jan 6 '13 at 0:02
Hi DerfK, Not sure if I follow you. Im just logging onto the server with my created <user> + defined <password> via Filezilla. Im logging on without any issues, just that the root dir when logging in, isnt the one i've tried to set in my above steps – user1231561 Jan 6 '13 at 0:13
If you're not using SFTP, then there must be an FTP server installed in centos. There are a number of different ones like proftpd, pureftpd, vsftpd, and so on. Each one has different configuration. Suku's answer will get your user to start in the directory, but they can leave the directory unless you configure the server to keep them there. – DerfK Jan 6 '13 at 1:35
Hi DerfK - thanks for elaborating. I can see when logging in that im using "vsFTPd". I just figured that it was possible to make that configuration in the process of creating user + group through SSH. Isnt there a SSH command that can take care of that? Or do I need to actually manually edit some local file related to the FTP configuration? – user1231561 Jan 6 '13 at 13:38
up vote 0 down vote accepted
useradd someuser -d /var/www/ -s /bin/false
passwd someuser


If I want to change already created user's home directory and shell, use following command:

sudo usermod someuser -d /home/someuser -s /bin/bash

If a user have /bin/false as the shell, that user can't login via ssh/Xorg or in another words, /bin/false is not a login shell

share|improve this answer
Hi Suku. Thanks a lot. I will just try this out. Wuld you be able to tell me what "-s /bin/false" <- does? Lets assume i've already created my user through basic "useradd <username>" - how would I go about changing that user to a new directory? In your example we're defining it from start (which I will do in the future), but just wondering what I do in the case im currently in, where ive created a user in /home/username - and want to change that folder to something else. – user1231561 Jan 6 '13 at 13:42
@user1231561 See the edit in answer. If this helped, please accept/upvote the answer. – Suku Jan 6 '13 at 13:52

Your Answer


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.