如何使用阿里雲主機(Ubuntu)搭建FTP伺服器(超詳細)
由於需要上傳程式碼檔案,又不能直接給所有SSH來連線,於是只能搭建個ftp伺服器了,記錄整個過程。
1、安裝vsftpd
sudo apt-get install vsftpd
2、sudo vi /etc/vsftpd.conf並寫入如下
# Example config file /etc/vsftpd.conf # Allow anonymous FTP? (Disabled by default). # Uncomment this to allow local users to log in. # Uncomment this to enable any form of FTP write command. # Default umask for local users is 077. You may wish to change this to 022, # Activate directory messages - messages given to remote users when they # # You may override where the log file goes if you like. The default is shown
# This option should be the name of a directory which is empty. Also, the # This option specifies the location of the RSA certificate to use for SSL # |
3、重啟服務
systemctl restart vsftpd.service
設定開機自啟動
systemctl enable vsftpd.service
4、建立共享資料夾
mkdir /home/myftp
給這個資料夾所有許可權
chmod 777 -R /home/myftp
5、建立使用者byk和密碼
sudo useradd -d /home/myftp/ -s /bin/bash byk
設定密碼
sudo passwd byk
輸入密碼,然後
sudo vi /etc/vsftpd.chroot_list把使用者byk寫入,重啟服務。
注意,想要put檔案必須給這個檔案所有許可權,不然會報錯,put是ftp的命令,即上傳檔案的意思,具體命令使用請自查。
6、開放阿里雲主機ftp執行的埠
netstat -atunp | grep ftp檢視ftp埠為21,於是去開放21埠。
7、使用windows遠端連線
開啟internet選項->高階->使用被動FTP去掉勾,儲存
在檔案瀏覽器位址列輸入ip
輸入密碼
ok,可以愉快地使用ftp了。