安裝 sublime text sftp

shift+command+p > Package Control:Install Package > sftp

開啟設定檔

File>SFTP/FTP/Setup Server

這時會開啟一個json格式的設定檔案

查看 vagant ssh-config

首先,先查看vagant ssh-config

$ vagrant ssh-config
Host homestead-7
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/liaoxiangru/Homestead/.vagrant/machines/homestead-7/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes

SFTP CONFIG 檔案

設定 Sftp config 檔案,填寫對應資訊

例如:

{
    // 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",

    "sync_down_on_open": true,
    "sync_same_age": true,
    
    "host": "127.0.0.1",
    "user": "vagrant",
    //"password": "password",
    "port": "2222",
    
    "remote_path": "/home/vagrant/code",
    //"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,
}

接著存擋為 sftp-config.json

Browser Server

File>SFTP/FTP/Browser Server > sftp-config.json

接著就可以逐步選取開啟遠端檔案

Upload file

編輯檔案後,在頁籤 ctrl+右鍵 > upload file