2

I setup vsftp with my ftp users' home directory at /var/www but I realized, it wouldn't let em login by ftp, I tried to connect to 127.0.0.1. So then i wanted to "try out" my ftp user on the shell but I get this:

reg@regDesktopHome:~$ whoami
reg
reg@regDesktopHome:~$ su - ftp
Password: 
reg@regDesktopHome:~$ whoami
reg

Why does su not let me change the current user I'm wondering?

  • 1
    You can do this with "shell-less" accounts by doing a "sudo -u ftp bash". You won't get a login shell, but you will be user 'ftp' with its permissions. That can be quite handy when you're trying to debug a script that runs in some service account, etc. – Stabledog Feb 23 '14 at 1:47
2

You cannot login to the accounts that do not have a shell associated to them.

$ getent passwd ftp
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin

Note that the shell is set to /sbin/nologin. This account is meant for the vsftp daemon to run under, it's not meant to be logged into.

NOTE: You can still do things as this user, just not get a shell. One method would be via sudo:

$ sudo -u ftp touch /tmp/afile
$ ls -l /tmp/afile 
-rw-r--r--. 1 ftp ftp 0 Feb 22 20:27 /tmp/afile

So you could touch a file to the directory /var/www to see if the user can write to this directory.

  • Here it looks like ftp:x:121:131:ftp daemon,,,:/var/www/:/bin/false – stdcerr Feb 23 '14 at 1:25
  • @cerr - that's another way to do the same thing. The shell is set to /bin/false. – slm Feb 23 '14 at 1:25
  • yep, i realized, thx! – stdcerr Feb 23 '14 at 1:41

Your Answer

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

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