【extension】sftp
產生Config
vscode 按下 Ctrl + Shift + P
輸入 SFTP:Config
Config 相關
單一來源
[
{
"name": "demo_10.1.1.1",
"context": "D:\\php_workspace\\demo",
"host": "10.1.1.1",
"username": "user1",
"password": "12345678",
"remotePath": "/root"
}
]
多個來源
[
{
"name": "demo_10.1.1.1",
"context": "D:\\php_workspace\\demo\web1",
"host": "10.1.1.1",
"username": "user1",
"password": "12345678",
"remotePath": "/root"
},
{
"name": "demo_10.1.1.2",
"context": "D:\\php_workspace\\demo\web2",
"host": "10.1.1.2",
"username": "user1",
"password": "12345678",
"remotePath": "/root"
},
]
使用跳板機(帳號密碼)
[
{
"name": "jump_demo",
"remotePath": "/root",
"context": "D:\\php_workspace\\jump_demo",
"host": "10.1.1.1", // 跳板機ip
"username": "user1", // 跳板機 帳號
"password": "12345678", // 跳板機 密碼
"hop": {
"host": "192.168.1.1", // 目的地ip
"port": 22,
"username": "target_user", // 目的地 帳號
"password": "66778899" // 目的地 密碼
},
// 排除檔案
"ignore": [
".vscode",
".git",
".DS_Store",
"**/logs/**",
"**/sessions/**"
],
// 儲存後自動上傳
"uploadOnSave": false
}
]
使用跳板機(憑證)
[
{
"name": "jump_demo",
"remotePath": "/root",
"context": "D:\\php_workspace\\jump_demo",
"host": "10.1.1.1", // 跳板機ip
"username": "user1",
"password": "12345678",
"hop": {
"host": "192.168.1.1", // 目的地ip
"port": 22,
"username": "target_user",
"privateKeyPath": "/home/user1/.ssh/id_rsa" //使用憑證(跳板機位置)
},
// 排除檔案
"ignore": [
".vscode",
".git",
".DS_Store",
"**/logs/**",
"**/sessions/**"
],
// 儲存後自動上傳
"uploadOnSave": false
}
]
第一次設定完,可以按下【Ctrl + Shift + P 】(Mac: Cmd + Shift + P)
鍵入 >SFTP:Sync Remote -> Local
先將遠端資料同步至本機
瀏覽遠端檔案/選取Server檔案至本地編輯
選取左側icon
,展開目錄找到要編輯檔案,【Edit in Local】
檔案比較
在本地編輯的時候,可以按右鍵【Diff with Remote】與server 檔案比較
上傳,下載檔案
可以按右鍵,【Upload/ Download】上傳本地檔案至Server 或是 下載Server 檔案