1. 程式人生 > >Mac OS與Windows之間檔案共享/傳輸的最簡便方法

Mac OS與Windows之間檔案共享/傳輸的最簡便方法

使用mac os有一段時間了,可與我的windows系統的筆記本一直沒有方便的傳輸過檔案,都是通過QQ。今天實在無法忍受,決定找一個簡單的辦法

To enable SFTP access to your Mac:

  1. Open System Preferences and select Sharing System Preferences - Sharing - SFTP - OSX-1.png
  2. Next, make sure that Remote Login is enabled. You can allow any of the user accounts on your system to connect through remote login or you can specific specific users that you’d like to connect. If you’d like to create an account for a specific individual that doesn’t have access on your account then see additional details in the next section of this article. Sharing - Remote Login.png
  3. With remote login enabled, your sftp server on your Mac is enabled and you should be able to connect to your Mac with SFTP. Open any SFTP supported FTP client (We useCyberduck) enter your IP address, your account username to login to your Mac and your password. Be sure the port is set to 22 and click connect. If everything is working correctly you should be able to access your Mac file system and folder structure.
備註:

(1). 通過上述方式配置後,使用命令列也是可以連線的

(2). 預設OpenSSH是不支援密碼方式驗證的,需要編輯/etc/sshd_config檔案,將PasswordAuthentication設定為on

 1)保證MacOS與Windows屬於相同的工作組。

             Windows設定工作組我就不說了(這個大家都知道^_^),這裡說一下MacOS設定工作組的步驟:

             a)點選“Finder”--->“服務”--->“服務偏好設定”選單項,顯示如下介面: 

MacOS訪問Windows共享 - china.ygw - ^_^ china.ygw的部落格

                   如果顯示不是如上圖所示,則點選實際介面上邊的“全部顯示”按鈕,就會出來以上介面。

             b)在上圖中點選“網路”圖示,然後在出來的視窗中點選“高階”按鈕,隨後出來的視窗中點選“WINS”標籤,如下圖所示:

MacOS訪問Windows共享 - china.ygw - ^_^ china.ygw的部落格

              c)只需要確認上圖的“工作組”名稱與Windows系統的工作組名稱一致就行。

        2)設定MacOS與Windows系統的IP為同一網段

              Windows系統的IP設定也不多說了,以下說一下MacOS系統的IP地址設定。

             在上圖(網路窗體)中,點選“TCP/IP”標籤,然後在“配置IPv4”選項中選擇“手動”設定,依次輸入與Windows系統相同網段的IP地址與掩碼即可。

        3)設定Windows共享資料夾

              這個也不多說了。

        4)MacOS訪問Windows共享資料夾

             點選“Finder”--->“前往”--->“連線伺服器”選單項,顯示如下窗體:

MacOS訪問Windows共享 - china.ygw - ^_^ china.ygw的部落格

               如上圖,伺服器地址格式為“smb://xxx.xxx.xxx.xxx”,其中,xxx.xxx.xxx.xxx為Windows系統的地址。填寫完伺服器地址後,可以點選右邊的“+”按鈕進行伺服器地址的儲存(便於下次直接訪問),點選下邊的“連線”按鈕進行連線Windows共享資料夾,並在認證框中輸入共享資料夾的使用者名稱與口令,即可出現Windows共享資料夾內容。

        在實驗過程中發現一個非常詭異的問題:將Mac OS的sftp開啟後,始終無法通過SSH Secure Shell的File Transfer工具傳輸檔案(具體表現為連線後始終無法列出目錄下的檔案),但可以通過SSH Secure Shell的命令列工具接入SSH伺服器。

        苦苦研究很久無果,後來在OpenSSH網站看到他們推薦接入的客戶端,其中有FileZilla、WinSCP等,唯獨沒發現SSH Secure Shell。使用FileZilla和WinSCP連線SFTP,果然好使,於是確定不是SFTP配置的問題,問題必然出在SSH Secure Shell上。

        想想SSH Secure Shell也是老牌的工具了,而且之前我可以用這個工具連線公司開發環境的SFTP的,為什麼不支援Mac OS下Open SSH的SFTP呢?

        很自然的下載了最新版本的SSH Secure Shell,版本號為3.2.9,試驗後發現能夠正常連線Mac OS下的SFTP了,豁然開朗。我之前裝的是版本3.1.0,很想知道這兩個版本之間到底修正了哪些問題,這個bug有點大啊!