LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-24-2017, 10:49 AM   #1
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Rep: Reputation: Disabled
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

Last edited by Entropy1024; 07-24-2017 at 11:12 AM.
 
Old 07-24-2017, 11:30 AM   #2
dejank
Member
 
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
Quote:
Originally Posted by Entropy1024 View Post
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.
 
Old 07-24-2017, 11:34 AM   #3
dejank
Member
 
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
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
 
Old 07-24-2017, 11:34 AM   #4
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
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
 
Old 07-24-2017, 11:45 AM   #5
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
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!?
 
Old 07-24-2017, 11:59 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,483

Rep: Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091
What client application are you using to connect to the server?
 
Old 07-24-2017, 12:01 PM   #7
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
What client application are you using to connect to the server?
I've just been using AndFTP on Android.
 
Old 07-24-2017, 12:05 PM   #8
dejank
Member
 
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
That client can use sftp, are you sure that you are not using that instead of ftp?
 
Old 07-24-2017, 12:07 PM   #9
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dejank View Post
That client can use sftp, are you sure that you are not using that instead of ftp?
Yes i'm using SFTP to connect
 
Old 07-24-2017, 12:09 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,483

Rep: Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091
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
 
Old 07-24-2017, 12:11 PM   #11
dejank
Member
 
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
Quote:
Originally Posted by Entropy1024 View Post
Yes i'm using SFTP to connect
Well, sftp uses ssh for connection, not ftp. So no wonder that you can connect Disable ssh and you will not be able to.
 
Old 07-24-2017, 12:16 PM   #12
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dejank View Post
Well, sftp uses ssh for connection, not ftp. So no wonder that you can connect 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
 
Old 07-24-2017, 12:22 PM   #13
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
ufw possibly help?

short version on the ftp "server"
Code:
sudo ufw deny 21
sudo ufw allow from <friendly_IP> to any port 21
 
Old 07-24-2017, 12:24 PM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,483

Rep: Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091Reputation: 4091
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.
 
2 members found this post helpful.
  


Reply

Tags
ftp, ssh


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH client stops working after wake and after disabling/enabling the network halfpower Linux - Networking 2 08-09-2014 06:57 AM
Enabling and Disabling DCA hjazz6 Linux - General 2 04-02-2010 02:08 AM
Enabling/Disabling Wireless Radio. How? citiz3n Linux - Wireless Networking 3 05-26-2008 07:56 PM
Disabling/enabling the wireless card evilmonkey Linux - Hardware 5 05-17-2006 09:26 PM
Disabling the chroot in proftpd and enabling root logins on ssh/proftpd jon_k Linux - Software 1 06-16-2004 10:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration