LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Enabling/disabling VSFTPD via SSH (https://www.linuxquestions.org/questions/linux-newbie-8/enabling-disabling-vsftpd-via-ssh-4175610492/)

Entropy1024 07-24-2017 10:49 AM

Enabling/disabling VSFTPD via SSH
 
I have an FTP server set up on my Ubuntu box using vsftpd.

I only need to access it infrequently, therefore for security reasons I was wondering if there was a simple way to enable/disable it via SSH.

I did try SSHing in and using
Quote:

sudo service vsftpd stop
However it was still accepting clients fine.

Many thanks for any help.
Tim

dejank 07-24-2017 11:30 AM

Quote:

Originally Posted by Entropy1024 (Post 5739256)
I have an FTP server set up on my Ubuntu box using vsftpd.

I only need to access it infrequently, therefore for security reasons I was wondering if there was a simple way to enable/disable it via SSH.

I did try SSHing in and using

However it was still accepting clients fine.

Many thanks for any help.
Tim

If you are using ubuntu 15.04 or older:

1. To stop till next reboot

Code:

sudo stop vsftpd
2. To start till next stop/reboot

Code:

sudo start vsftpd
3. To check status

Code:

sudo status vsftpd
4. To restart

Code:

sudo restart vsftpd
5. To disable service activation on startup

Code:

echo manual | sudo tee /etc/init/vsftpd.override
6. To enable it again

Code:

sudo rm /etc/init/vsftpd.override
As a side note, not sure if vsftp service is called vsftp, or vsftpd. But it is easy to find out.

dejank 07-24-2017 11:34 AM

If you are using ubuntu 15.10 or newer, you are dealing with systemd.

To start

Code:

sudo systemctl start vsftpd.service
To stop

Code:

sudo systemctl stop vsftpd.service
To restart

Code:

sudo systemctl restart vsftpd.service
To enable

Code:

sudo systemctl enable vsftpd.service
To disable

Code:

sudo systemctl disable vsftpd.service
To check status

Code:

sudo systemctl status vsftpd.service

Entropy1024 07-24-2017 11:34 AM

Sorry my version info was out of date, I'm on 16.04.

I did try
Code:

sudo stop vsftpd
and
Code:

sudo stop vsftp
with the following error:
Code:

stop: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused

Entropy1024 07-24-2017 11:45 AM

using your
Code:

sudo systemctl stop vsftpd.service
then
Code:

sudo systemctl status vsftpd.service
I get back
Code:

Jul 24 17:35:31 p5e systemd[1]: Stopped vsftpd FTP server.
However it's still letting clients connect!?

michaelk 07-24-2017 11:59 AM

What client application are you using to connect to the server?

Entropy1024 07-24-2017 12:01 PM

Quote:

Originally Posted by michaelk (Post 5739276)
What client application are you using to connect to the server?

I've just been using AndFTP on Android.

dejank 07-24-2017 12:05 PM

That client can use sftp, are you sure that you are not using that instead of ftp?

Entropy1024 07-24-2017 12:07 PM

Quote:

Originally Posted by dejank (Post 5739281)
That client can use sftp, are you sure that you are not using that instead of ftp?

Yes i'm using SFTP to connect

michaelk 07-24-2017 12:09 PM

sftp is not the same as ftp.

Look at the output of the nmap command to confirm that the ftp port is inactive.

nmap IP_address -p 21

dejank 07-24-2017 12:11 PM

Quote:

Originally Posted by Entropy1024 (Post 5739283)
Yes i'm using SFTP to connect

Well, sftp uses ssh for connection, not ftp. So no wonder that you can connect :p Disable ssh and you will not be able to.

Entropy1024 07-24-2017 12:16 PM

Quote:

Originally Posted by dejank (Post 5739285)
Well, sftp uses ssh for connection, not ftp. So no wonder that you can connect :p Disable ssh and you will not be able to.

Ah OK. But then I will not be able to turn it on again over SSH. OK I need another way of doing this then :)

Habitual 07-24-2017 12:22 PM

ufw possibly help?

short version on the ftp "server"
Code:

sudo ufw deny 21
sudo ufw allow from <friendly_IP> to any port 21


michaelk 07-24-2017 12:24 PM

vsftpd stands for Very Secure FTP Daemon. As stated it is not a sftp server which is a subsystem of ssh. There is no inherent reason to disable sftp as it is just as secure as ssh.

I assume that your not really using vsftpd so disabling it is a good idea.


All times are GMT -5. The time now is 12:29 AM.