• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux Simple FTP tutorial [Debian & Ubuntu]

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
7,030
Solutions
256
Reaction score
2,117
Location
Norway
GitHub
Znote
Hello, here is my simple FTP tutorial for Linux. :)

What are we going to do in this tutorial?
1. Install FTP server.
2. Create 2 users, 1 to handle website files and 1 to handle OT files.

Preparation:
Ubuntu users don't need preparation to follow this tutorial, however if you are Debian user, you should get sudo and nano before continuing. (optional, but it makes my tutorial copy-paste friendly).

This is very easy, do these commands:
Code:
su
== It might ask for root password, write it ==
Code:
apt-get install sudo
Code:
Y
Command Y for "yes, I want to install sudo".
Code:
apt-get install nano
Code:
Y
Command Y for "yes, I want to install nano".
Code:
exit
With this command you exit your "su" (admin login), hopefully you will never have to enter it again.
Thats it, Debian preparation done. Now feel free to follow my instructions:

Lets get started!
Part 1:
Install proftpd
Code:
sudo apt-get install proftpd
== It might ask for root password, write it ==
You get option to install 2 things, choose "Standalone"!
yep, you want to install it.
Code:
Y
Edit proftpd shells and add /bin/false at the end of the document. (You don't need to understand this, just do it).
Code:
sudo nano /etc/shells
== It might ask for root password, write it, you want to edit the file ==
  • You are now in the nano text editor, use your arrows to navigate to the bottom of the document, and write
    Code:
    /bin/false
  • Then click CTRL + O
  • Then click ENTER. You have now saved the document.
  • Then click CTRL + X to exit the text document. You are done here now.

Fix so users are restricted to their default dir only:
Code:
sudo nano /etc/proftpd/proftpd.conf
CTRL + W (write DefaultRoot) [Click ENTER].
Change this line:
Code:
# DefaultRoot                     ~
With this: (Basically you just remove the square (#) and the space.
Code:
DefaultRoot                     ~
Click CTRL + O (Then click ENTER). [Save changes].
Click CTRL + X [Exit text document].

FTP server is now prepared for what we need. :)

Now its time to make a dir to the OT server.
Enter your home folder.
Code:
cd /home/
Make a folder to your OT server.
Code:
sudo mkdir otserver

Give the folder otserver full permission. (So you can edit, delete, upload, download files in that folder).
Code:
sudo chmod 777 -R otserver

Now it is time to create an FTP user that got access to only the folder otserver.
Code:
sudo useradd USERNAME -p PASSWORD -d /home/otserver -s /bin/false
== Remember to change USERNAME to your desired FTP username, and PASSWORD as the password your desired username shall have. ==

Now in order to make it work through etc FileZilla, for some weird reason we need to change the password. It won't let you connect through default user password.
Code:
passwd "USERNAME"
NEWPASSWORD
NEWPASSWORD
You write NEWPASSWORD twice to avoid spelling mistakes.

Thats it, you have successfully added the user. You do not have to launch anything, everything else is automatic. You can now login with username/password on any FTP client that you have, and it will work. :)
Note: You will have to port forward to get results over the Internet. This tutorial uses base port (21, 22) as default.
Znote said:
Note2: If you are using linux iptables as firewall, you might also need to allow some passive ports thought input and output, without going through iptable details, I will throw out one iptable sample:
-A INPUT -p tcp --dport 60000:65000 -s 123.123.123.123 -j ACCEPT
Replace 123.123~ with your IP address. Or remove -s 123(ip) to allow everyone to access proftp server. (this is not recommended, as you will open tons of ports to public).
You also should configure passive ports in proftpd.conf file, search after "PassivePorts" and write the port range 60000 65000, then save.
Part 2:
In this part we will add a user that will be granted access to the website files.
Before you continue here, you have to make sure you have done the first step in Stian tutorial: http://otland.net/f479/ubuntu-nothi...gotten-server-modernaac-mysql-lighttpd-89001/
Make sure you have done the "Mysql / Webserver" step from him before continuing here.

Enter the folder that contains the www folder. /htdocs folder.
Code:
cd var

Give the www folder full permission.
Code:
sudo chmod 777 -R www
(In order to keep it as simple as possible, this might not be the most secure way).
Offtopic: Make sure to use Modern AAC not Gesior as website. ;)

Now it is time to create an FTP user that got access to only the folder www.
Code:
sudo useradd USERNAME -p PASSWORD -d /var/www -s /bin/false
== Remember to change USERNAME to your desired FTP username, and PASSWORD as the password your desired username shall have. ==
Note: Don't use same username and password as for the otserver!

Now in order to make it work through etc FileZilla, for some weird reason we need to change the password. It won't let you connect through default user password.
Code:
passwd "USERNAME"
NEWPASSWORD
NEWPASSWORD
You write NEWPASSWORD twice to avoid spelling mistakes.

Thats it, you have successfully added the user.

Well, thats it actually. No more hazzle needs to be doing. You can connect to your otserver using the username and password you wrote for the otserver folder.

And you can connect to your www (htdocs) folder using the username and password you wrote for the www folder.

Extra stuff: You don't need to know this. The tutorial itself is already finished.
Comparing Windows and Linux.
When starting with Linux, you turn yourself to a different environment from windows. But there are similarities.
  • /home/ directory. This is similar to users and settings - my documents or something like that in windows.
  • /var/www directory. This is similar to xampp/htdocs or uniserv/www folder. This is were website files are located.
  • /etc/ directory. This is similar to Program Files folder. This is where installed programs are located.

When you open a folder, you don't double click an folder icon or anything. But you use the command "cd".

Example: cd /home/otserver/
Will open the folder otserver that is located in your home directory.

When you have opened a folder, you cant see anything, this is terminal after all. But how can I see what is inside the folder?
You can use the command ls (LS).

example:
cd /home/otserver
ls
And it will print out the names of each individual file in the folder.

Lets say you want to edit config.lua and change the IP address. What to do?
First lets locate the otserver.
cd /home/otserver
then we can type ls (LS) to see if we are at the correct place, if we can find config.lua

Then lets open it in nano text editor!
sudo nano config.lua

Now you are in text editor, you can clearly see the contents of config.lua in front of you.
Handy commands:
[Search]: CTRL + W (Then write what you want to search after, etc statusport)[Then click enter to search after it].
[Save As] CTRL + O (and then click Enter to save).
[Close text editor] CTRL + X

This was the ordinary Windows processing style. Instead of entering folder, check files, open file in nano, you can do all that in 1 simple command.
sudo nano /home/otserver/config.lua
Thats it, your in text editor editing config.lua. :)
 
Last edited:
Well. Isn't it just so much simpler if you choose to use sftp (ftp over ssh)? :p
 
Didn't think of that. And since I learned to use this one I am satisfied with it. :p

OP edited. (Forgot to make users uncomment DefaultRoot ~) for security reasons. :p
 
Make sure you have FTP ported correctly. :p
 
solved, only need to write in the console passwd "user", after this write the password :p

Ahh thanks. Did that on my test box. But forgot to commit it to the tutorial since I didn't think it really was necessarily. :p

Added now.
 
Note2: (retrieving directory listening issue)
If you are using linux iptables as firewall, you might also need to allow some passive ports thought input and output, without going through iptable details, I will throw out one iptable sample:
-A INPUT -p tcp --dport 60000:65000 -s 123.123.123.123 -j ACCEPT
Replace 123.123~ with your IP address. Or remove -s 123(ip) to allow everyone to access proftp server. (this is not recommended, as you will open tons of ports to public).
You also should configure passive ports in proftpd.conf file, search after "PassivePorts" and write the port range 60000 65000, then save.
 
Back
Top