最近再做一個web項目,目前決定先把應用放在云服務器上。我選擇的云主機是aliyun的Ubuntu 16.04主機。部署好云主機環境后,就需要把我在本地開發好的程序上傳到云主機了。剛開始打算用ftp協議來傳輸,于是參照網上的教程(Ubuntu 16.04下vsftpd 安裝配置實例_服務器應用_Linux公社-Linux系統門戶網站),安裝vsftpd,設置相關參數,本地安裝FileZilla。當一切都設好后,到最后一步卻卡住了,使用ftp協議FileZilla怎么都連不上云主機。在網上搜了很多方法都無效,大部分認為問題出在云主機的防火墻,但我檢查了我的云主機防火墻iptables服務根本沒開啟,最后還是沒有找到原因。
最后在Google上,搜解決辦法的時候,無意中看到有人說‘不要用ftp,ftp不安全的,早就該廢棄之類話’,而且提議用SFTP-SSH File Transfer Protocol來傳輸,而且FileZilla就支持該協議。二話不說,直接開試。點擊如上圖左上角的圖標,進入Site Manager界面,選擇SFTP協議,登錄方式選擇秘鑰登錄,秘鑰用的就是云主機的連接秘鑰。
點擊connect,大喜,果然急速連接成功。如下圖,左邊是本地目錄,右邊是云主機目錄,連接成功后才會顯示。上傳文件操作極易,只需把左邊的文件直接拖到右邊即可。
在terminal上查看云主機上的文件,剛剛拖進去的圖片已經在云主機的硬盤里了。
參考網站(可能需要FQ):
https://askubuntu.com/questions/315378/ubuntu-web-server-ftp-connection-timeout 第二個回答
https://ubuntuforums.org/showthread.php?t=2234950 第五個回答
以下是一位外國網友的留言,貼在下方可以參考一下:
I’m more concerned about anyone using FTP. That protocol should have died 15 yrs ago for a number of reasons. It is like telnet. You have ssh running already, so just use an sftp client. There are lots of nice clients for every platform, it will be secure since passwords aren’t transmitted as plain text. If you use Windows - WinSCP is a nice client. There are others. The commands map 1-for-1 to old-school FTP (by design), so there isn’t anything new to learn. Plus the 3 main FTP servers have each had back doors inserted in their source code over the years - I think it happened to 1 of them twice. Just for clarification, nobody has announced any back doors in the current FTP servers that I know. Also - about the only organizations that should still be using FTP are those that want so share all files on the system with the entire world and don’t care who grabs the files. FTP doesn’t usually play nice with firewalls either.
On my home network when NFS isn’t available between the systems, I usually use scp or rsync with ssh-key-based authentication. It is very convenient - much more than FTP or sftp. OTOH, I’ve been called “odd”, so I can completely understand folks using sftp between their Windows and unix-like systems. If you need lots of easy access from Windows, then CIFS (samba) which has next to ZERO security is what most organization use. Just to be fair, NFS can be configured with low security and no encryption too. Neither NFS nor CIFS should be used over the internet (at least without a good VPN).
If you just want to share files with the entire world, use http. If authenticated logins are needed, then scp/sftp are what you want. FTP should have been killed off years ago.