Enable FTP service in your linux server

FTP is a file transfer protocol that specifies how to transfer files across the internet, and in this blog, I am going to show how to enable an ubuntu server accessible via FTP.

Prerequisite

You should have an Ubuntu server instance running at hand. You can either apply a free one in AWS or any other cloud PaaS Provider.

Steps

  1. Login to your Linux server
    Install vsftpd in your server instance viasudo apt-get install vsftpd -y. once installation is down, the ftp service will start automatically, you can check via sudo netstat -nltp | grep 21, which tells a certain process is listening port 21. Alternately you can manually start the service via sudo systemctl start vsftpd.service.
  2. Create directory for your ftp service.
    sudo mkdir /home/uftp and sudo touch /home/uftp/welcome.txt will create a directory called 'uftp' and file welcome.txt in your directory.
  3. Create ftp user that can login to your server via ftp
    • sudo useradd -d /home/uftp -s /bin/bash uftp will create user 'uftp', you can specify another name as you like. Once the user is created, specify the password for user via sudo passwd uftp, you will be required to specify the password twice.
  4. Allow the files can be accessed via ftp
    By default you are not allowed to access any file via ftp, command sudo rm /etc/pam.d/vsftpd uncover the permission.
  5. Specify your created user can and can only access via ftp
    Command sudo usermod -s /sbin/nologin uftp can restrict your user can only access via ftp. Detailed access permission can be specified via sudo chmod a+w /etc/vsftpd.conf && vim /etc/vsftpd.conf. A sample specification is given below:
# 限制用户对主目录以外目录访问
chroot_local_user=YES

# 指定一个 userlist 存放允许访问 ftp 的用户列表
userlist_deny=NO
userlist_enable=YES

# 记录允许访问 ftp 用户列表
userlist_file=/etc/vsftpd.user_list

# 不配置可能导致莫名的530问题
seccomp_sandbox=NO

# 允许文件上传
write_enable=YES

# 使用utf8编码
utf8_filesystem=YES
  1. Add your created user to user list
    sudo touch /etc/vsftpd.user_list creates user list file that specifies only users specified here can access the server via ftp. You can modify the file via sudo chmod a+w /etc/vsftpd.user_list && vim /etc/vsftpd.user_list and add user 'uftp' in this file.
  2. Specify the directory permission
    sudo chmod a-w /home/uftp and sudo mkdir /home/uftp/public && sudo chmod 777 -R /home/uftp/public, the fisrt command tells that /home/uftp is only readable, and the second command tells /home/uftp/public is both readable and writable.
  3. Start your vsftpd service
    sudo systemctl restart vsftpd.service
  4. Access you remote ftp via FTP client
    • Windows
      In File Explorer you can enter below URL ftp://[user_name]:[password]@[your_cloud_vm_public_ip] .
    • Mac
      In *Finder app, click Go in menu and select Connect to Server (or user Command + K hot key), enter URL ftp://your_cloud_vm_public_ip], enter your username and password in pop-up screen, you will be logged in.
  • FTP Client
    FileZilla is a cross-platform ftp client that supports both Windows and Mac.
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,160评论 0 10
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 14,595评论 5 6
  • Getting Started Use the Current Stable Version (7.1) Buil...
    Leonzai阅读 5,952评论 0 3
  • 离开学校已经两年了,在这个城市里,我已经学会了像秋儿一样在春风中自在的奔跑,学会了静静地看花儿绽放,将一些身外之事...
    莲城阅读 3,926评论 0 48
  • 弯弯小河 淌在我心中 此起彼伏 缠绵难平 沉眠布莱屋 顺着梦境中悠悠话语 我沉醉其中 在兴奋,欢悦地感受幸福 在歌...
    荒草_冯权加阅读 1,631评论 4 3