工具:
sublime text 2(mac版)
遠程linux(centos 7系)
securCRT(for mac)
【本地安裝並配置securCRT(for mac)】
關於配置:
1、解決終端連接服務器短時間自動斷開連接的問題:
修改服務器sshd_config文件,直接修改 /etc/ssh_config文件
將 #ServerAliveCountMax 3
#ServerAliveInterval 0
的注釋去掉,並且 ServerAliveInterval 0 改為 ServerAliveInterval 5
參數備注 :
(1)ServerAliveCountMax 3 :表示服務器發出請求后客戶端沒有響應的次數達到一定值, 就自動斷開. 正常情況下, 客戶端不會不響應.
(2)ServerAliveInterval 0 :指定了服務器端向客戶端請求消息的時間間隔, 默認是0, 不發送.
而ServerAliveInterval 5表示每5秒向服務器發送一次,這樣就保持長連接了。
2、securCRT設置終端顏色
參考博客:https://blog.csdn.net/yulei_qq/article/details/47733327
【sublime text 2(mac版)的安裝配置】
(1)安裝:https://www.sublimetext.com/2 對應的插件install package安裝命令:https://packagecontrol.io/installation#st2
(2)想在本地mac的sublime上同步遠程linux的代碼,一種方法使用sublime自帶的sftp/ftp插件,另一種方法是使用samba。本文下來介紹如何使用使用sublime自帶的sftp/ftp插件:需要在本地sublime配置以及遠程linux配置兩部分:
第一部分:配置遠程linux主機(我的是centos 7系)
step1:安裝vsftp
yum -y install vsftpd
step2:修改配置文件
vi /etc/vsftpd/vsftpd.conf
保證下面3項為YES
anonymous_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
step3:設置vsftpd開機啟動
systemctl enable vsftpd.service
step4:啟動並查看vsftpd服務狀態,systemctl啟動服務成功不會有任何提示,綠色的active表示服務正在運行
systemctl start vsftpd.service
systemctl status vsftpd.service
第二部分:在本地sublime配置
step1: 插件安裝
用Package Control安裝插件
按下Ctrl+Shift+P調出命令面板
輸入install 調出 Install Package 選項並回車,然后輸入sftp,下拉列表中會出現一些相關的插件,選中sftp進行安裝就行。插件安裝過程可以查看Sublime左下角的狀態欄的信息。
step2:基本連接
插件安裝完成以后,需要進行配置。選菜單欄中的File->SFTP/FTP->Set up Server。這樣就會打開一個配置文件:
{ // The tab key will cycle through the settings when first created // Visit http://wbond.net/sublime_packages/sftp/settings for help // sftp, ftp or ftps "type": "sftp", "save_before_upload": true, // 支持ctrl + s自動同步到服務器 "upload_on_save": true, // 支持ctrl + s 自動同步到服務器 "sync_down_on_open": false, "sync_skip_deletes": false, "sync_same_age": true, "confirm_downloads": false, "confirm_sync": true, "confirm_overwrite_newer": false, "host": "ip", "user": "user", "password": "passwd", //"port": "22", "remote_path": "/home/admin/", "ignore_regexes": [ "\\.sublime-(project|workspace)", "sftp-config(-alt\\d?)?\\.json", "sftp-settings\\.json", "/venv/", "\\.svn/", "\\.hg/", "\\.git/", "\\.bzr", "_darcs", "CVS", "\\.DS_Store", "Thumbs\\.db", "desktop\\.ini" ], //"file_permissions": "664", //"dir_permissions": "775", //"extra_list_connections": 0, "connect_timeout": 30, //"keepalive": 120, //"ftp_passive_mode": true, //"ftp_obey_passive_host": false, //"ssh_key_file": "~/.ssh/id_rsa", //"sftp_flags": ["-F", "/path/to/ssh_config"], //"preserve_modification_times": false, //"remote_time_offset_in_hours": 0, //"remote_encoding": "utf-8", //"remote_locale": "C", //"allow_config_upload": false, }
我們需要配置一些遠程連接的基本信息,如上圖。遠程IP、用戶名、密碼、打開目錄。配置完成以后保存文件。
在選菜單欄中的File->SFTP/FTP->Browse Server 就可以看到自己配置的遠程連接信息了,然后選中連接即可。然后就可以瀏覽遠程服務器中的文件了。
step3:同步文件夾
先在本機mac下創建一個文件夾(最好使用英文),使用Sublime打開。
此時,右鍵左側sidbar中這個文件圖標,選擇SFTP/FTP: SFTP > Map to Remote…
然后會打開一個.json的配置文件。我們需要在這個文件中配置連接需要的信息。同上面的配置。
保存文件,右鍵文件圖標,SFTP > Download Folder,就可以把遠程文件夾的文件下載到同步的文件夾中了。以此類推,我們可以進行文件上傳、同步等操作。