0

I ran usermod -s /bin/false ftpuser2 and now I'm unable to use the FTP service with my secondary account. How can I revert this command?

If you ask me what I've tried, nothing, and don't wish to, because I'm newbie on this and I could broke things permanently and my hosting company is not going to provide me with assistance or backups.

chicks
  • 3,639
  • 10
  • 26
  • 36
Kevin
  • 1
  • 4

1 Answers1

1

To begin, the fact that your hosting company doesn't proide backups or snapshots of ANY kind is less than desireable. The vast majority of companies at least perform snapshots of their infrastructure periodically. That is, unless you've rejected that service. You may want to follow up with your hosting provider on that one, as you may have that kind of service without knowing about it.

But to answer our question, you've changed one plain text file with that command. If you can get into that server using any other user that has permission to modify system files (the user "root", for example, or any user that is a "sudoer" or "administrator"). To fix this, you could run the following:

sudo usermod -s /bin/sh ftpuser2

If sudo doesn't exist, then you need to log in as root. If you can't log in as root, then you've locked yourself out and you need to get some help getting in (or you need a new server instance).

Once you're back in, consult the '/etc/passwd' file for what your other users have set for their default shell, and set ftpuser2 to that shell rather than sh.

Later on, you may want to experiment with disabling a shell for the FTP user, as that is a common vulnerability. However, do it in a lab, not in production. And always be sure to have an administrative user account handy to help get yourself back in if you mess up.

Spooler
  • 7,016
  • 16
  • 29
  • hi, i would like to disable the SSH and SFTP for this user (`ftpuser2`) and leave FTP only. How can I do this? Thanks. – Kevin Sep 23 '17 at 01:55
  • 1
    If you have another question (which that is), then you should create another question on here instead. – Spooler Sep 23 '17 at 02:01
  • Or just google "SSH deny user" - generally ssh and sftp are done by the same daemon, but FTP is a separate service, so you can just block the user in sshd_config. – James Shewey Sep 23 '17 at 04:56