1. 程式人生 > >雲伺服器檔案傳輸問題

雲伺服器檔案傳輸問題

最近再做一個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上檢視雲主機上的檔案,剛剛拖進去的圖片已經在雲主機的硬盤裡了。
這裡寫圖片描述

以下是一位外國網友的留言,貼在下方可以參考一下:

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.