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:
# 限制用戶對(duì)主目錄以外目錄訪問(wèn)
chroot_local_user=YES

# 指定一個(gè) userlist 存放允許訪問(wèn) ftp 的用戶列表
userlist_deny=NO
userlist_enable=YES

# 記錄允許訪問(wèn) ftp 用戶列表
userlist_file=/etc/vsftpd.user_list

# 不配置可能導(dǎo)致莫名的530問(wèn)題
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.
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,854評(píng)論 0 10
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,657評(píng)論 5 6
  • Getting Started Use the Current Stable Version (7.1) Buil...
    Leonzai閱讀 2,066評(píng)論 0 3
  • 離開(kāi)學(xué)校已經(jīng)兩年了,在這個(gè)城市里,我已經(jīng)學(xué)會(huì)了像秋兒一樣在春風(fēng)中自在的奔跑,學(xué)會(huì)了靜靜地看花兒綻放,將一些身外之事...
    蓮城閱讀 738評(píng)論 0 48
  • 彎彎小河 淌在我心中 此起彼伏 纏綿難平 沉眠布萊屋 順著夢(mèng)境中悠悠話語(yǔ) 我沉醉其中 在興奮,歡悅地感受幸福 在歌...
    荒草_馮權(quán)加閱讀 266評(píng)論 4 3

友情鏈接更多精彩內(nèi)容