### Simple SFTP Configuration Example Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md A minimal JSON configuration for the SFTP extension, specifying only the essential connection details: host, username, and the remote path. This serves as a starting point for basic SFTP synchronization. ```json { "host": "host", "username": "username", "remotePath": "/remote/workspace" } ``` -------------------------------- ### Basic SFTP Configuration Example Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/configuration.md A fundamental configuration for connecting to an SFTP server. This example demonstrates setting a server name, protocol, host, port, username, and the remote path for file transfers. Ensure the 'protocol' is set to 'sftp'. ```json { "name": "My Server", "protocol": "sftp", "host": "server.example.com", "port": 22, "username": "user1", "remotePath": "/_subfolder_" } ``` -------------------------------- ### Basic SFTP Configuration (JSON) Source: https://github.com/natizyskunk/vscode-sftp/wiki/Configuration Defines the basic connection parameters for an SFTP server, including name, host, port, and username. This is the minimum required for establishing a connection. ```json { "name": "My Server", "host": "server.example.com", "port": 22, "username": "user1" } ``` -------------------------------- ### SFTP Project Configuration (JSON) Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md This example shows how to link a project's SFTP configuration to a remote environment defined in `remotefs.remote`. It specifies which remote environment to use ('dev'), the remote path, and optional settings like `uploadOnSave` and file exclusion patterns. ```json { "remote": "dev", "remotePath": "/home/xx/", "uploadOnSave": false, "ignore": [".vscode", ".git", ".DS_Store"] } ``` -------------------------------- ### FTP(S) Security Configuration (JSON) Source: https://github.com/natizyskunk/vscode-sftp/wiki/Configuration Enables and configures secure connections for FTP, specifying whether to use FTPS and providing options for secure connections. ```json { "protocol": "ftp", "secure": true } ``` -------------------------------- ### SFTP Synchronization Options (JSON) Source: https://github.com/natizyskunk/vscode-sftp/wiki/Configuration Configures the behavior of the 'Sync' command, allowing options to delete extraneous files, skip creating new files, or ignore existing files on the destination. ```json { "syncOption": { "delete": true, "skipCreate": false, "ignoreExisting": false } } ``` -------------------------------- ### SFTP Authentication Configuration (JSON) Source: https://github.com/natizyskunk/vscode-sftp/wiki/Configuration Configures authentication for SFTP connections using either a password or a private key. Passwords are stored in plain text, while private key authentication offers more security. ```json { "username": "user1", "password": "Password123" } ``` ```json { "username": "user1", "privateKeyPath": "~/.ssh/id_rsa" } ``` -------------------------------- ### SFTP Remote Path and Permissions (JSON) Source: https://github.com/natizyskunk/vscode-sftp/wiki/Configuration Specifies the remote directory path and file/directory permissions for new files and folders on the server. These settings control where files are uploaded and their access rights. ```json { "remotePath": "/_subfolder_", "filePerm": 644, "dirPerm": 750 } ``` -------------------------------- ### Set SFTP File and Directory Permissions Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Configure Unix file and directory permissions for uploaded files. This ensures that uploaded content has the correct access rights on the remote server. Common permission values for files and directories are provided as examples. ```json { "host": "example.com", "username": "deploy", "remotePath": "/var/www", "protocol": "sftp", "filePerm": 644, // rw-r--r-- for files "dirPerm": 755, // rwxr-xr-x for directories "uploadOnSave": true } // Common permission values: // Files: // 644 (rw-r--r--) - Owner can write, others read // 600 (rw-------) - Owner only // 664 (rw-rw-r--) - Owner and group can write // Directories: // 755 (rwxr-xr-x) - Owner full, others read/execute // 750 (rwxr-x---) - Owner full, group read/execute // 700 (rwx------) - Owner only ``` -------------------------------- ### SFTP Upload Behavior Configuration (JSON) Source: https://github.com/natizyskunk/vscode-sftp/wiki/Configuration Controls how files are uploaded, including automatic uploads on save, using temporary files to prevent corruption, and enabling atomic uploads for OpenSSH servers. ```json { "uploadOnSave": true } ``` ```json { "useTempFile": true } ``` ```json { "openSsh": true, "useTempFile": true } ``` -------------------------------- ### Pass Custom SSH Parameters and Algorithms Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Provide custom parameters and algorithms for the SSH connection. This allows for advanced configurations, such as specifying non-standard ports, disabling strict host key checking, or defining specific key exchange, cipher, and server host key algorithms for compatibility with older or specific server setups. ```json { "host": "example.com", "username": "user", "protocol": "sftp", "privateKeyPath": "~/.ssh/id_rsa", "sshCustomParams": "-p 2222 -o StrictHostKeyChecking=no", "algorithms": { "kex": [ "ecdh-sha2-nistp256", "diffie-hellman-group-exchange-sha256" ], "cipher": [ "aes128-ctr", "aes192-ctr", "aes256-ctr" ] }, "interactiveAuth": true } // Algorithm customization for older servers: { "algorithms": { "kex": [ "diffie-hellman-group1-sha1" ], "cipher": [ "aes128-cbc" ], "serverHostKey": [ "ssh-rsa", "ssh-dss" ] } } ``` -------------------------------- ### Initialize Basic SFTP Configuration (JSON) Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Sets up a basic SFTP configuration file (.vscode/sftp.json) for a production server. It includes connection details, remote path, and upload-on-save settings, along with a list of files/folders to ignore. ```json { "name": "Production Server", "host": "example.com", "protocol": "sftp", "port": 22, "username": "deploy", "password": "your-password", "remotePath": "/var/www/html", "uploadOnSave": true, "ignore": [ ".vscode", ".git", ".DS_Store", "node_modules" ] } ``` -------------------------------- ### SFTP: Create Configuration File Source: https://github.com/natizyskunk/vscode-sftp/wiki/Commands Creates a new configuration file for an SFTP project. This command is essential for setting up project-specific SFTP connections and settings. ```plaintext SFTP: Config ``` -------------------------------- ### SFTP Configuration with Profiles Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md This JSON configuration demonstrates the use of profiles for managing multiple remote server connections within the SFTP extension. It includes global settings and specific configurations for 'dev' and 'prod' profiles, allowing users to switch between them. The `watcher` configuration enables automatic uploads based on file patterns. ```json { "username": "username", "password": "password", "remotePath": "/remote/workspace/a", "watcher": { "files": "dist/*.{js,css}", "autoUpload": false, "autoDelete": false }, "profiles": { "dev": { "host": "dev-host", "remotePath": "/dev", "uploadOnSave": true }, "prod": { "host": "prod-host", "remotePath": "/prod" } }, "defaultProfile": "dev" } ``` -------------------------------- ### SFTP Configuration: Download and Synchronization Options Source: https://github.com/natizyskunk/vscode-sftp/wiki/Common-Configuration Configures automatic downloading of files upon opening and defines behavior for the `Sync` command. `downloadOnOpen` fetches remote files when they are accessed. `syncOption` allows controlling deletion of extraneous files, skipping creation, ignoring existing files, and updating based on modification time. ```json { "downloadOnOpen": true, "syncOption": { "delete": true, "skipCreate": false, "ignoreExisting": false, "update": true } } ``` -------------------------------- ### Multiple SFTP Server Profiles Configuration (JSON) Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Defines multiple server environments within a single configuration, allowing users to switch between profiles (e.g., dev, staging, production). This enables flexible deployment to different environments using a default profile. ```json { "username": "developer", "password": "devpass", "remotePath": "/app", "uploadOnSave": true, "ignore": [".git", "node_modules"], "profiles": { "dev": { "host": "dev.example.com", "remotePath": "/var/www/dev", "uploadOnSave": true }, "staging": { "host": "staging.example.com", "remotePath": "/var/www/staging", "uploadOnSave": false }, "production": { "host": "prod.example.com", "remotePath": "/var/www/prod", "uploadOnSave": false } }, "defaultProfile": "dev" } // Switch profiles using Command Palette: "SFTP: Set Profile" ``` -------------------------------- ### SFTP Configuration: Basic Connection Details Source: https://github.com/natizyskunk/vscode-sftp/wiki/Common-Configuration Defines essential connection parameters for establishing an SFTP or FTP connection. Includes a name for identification, protocol type, server hostname, port number, and authentication credentials (username and password). Passwords are stored in plain text and should be handled with care. ```json { "name": "My Server", "protocol": "sftp", "host": "server.example.com", "port": 22, "username": "user1", "password": "Password123" } ``` -------------------------------- ### VSCode SFTP Extension Commands Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt A comprehensive list of commands provided by the VSCode SFTP extension, accessible via the Command Palette. These commands facilitate configuration, profile management, file uploads, downloads, synchronization, comparison, remote operations, navigation, and utility functions. ```typescript // Configuration: // - SFTP: Config - Create/edit configuration file // Profile Management: // - SFTP: Set Profile - Switch between configured profiles // Upload Commands: // - SFTP: Upload File // - SFTP: Upload Folder // - SFTP: Upload Active File // - SFTP: Upload Active Folder // - SFTP: Upload Project // - SFTP: Upload Changed Files (Ctrl+Alt+U) // - SFTP: Force Upload // Download Commands: // - SFTP: Download File // - SFTP: Download Folder // - SFTP: Download Active File // - SFTP: Download Active Folder // - SFTP: Download Project // - SFTP: Force Download // Sync Commands: // - SFTP: Sync Local -> Remote // - SFTP: Sync Remote -> Local // - SFTP: Sync Both Directions // Compare Commands: // - SFTP: Diff with Remote // - SFTP: Diff Active File with Remote // Remote Operations: // - SFTP: Create File // - SFTP: Create Folder // - SFTP: Delete (remote file/folder) // - SFTP: List // - SFTP: List Active Folder // - SFTP: List All // Navigation: // - SFTP: Reveal in Explorer // - SFTP: Reveal in Remote Explorer // Remote Explorer: // - SFTP: Edit in Local // - SFTP: View Content // - SFTP: Refresh // Utilities: // - SFTP: Open SSH in Terminal // - SFTP: Cancel All Transfers // - View: Show SFTP (open Remote Explorer) ``` -------------------------------- ### Basic SFTP Configuration Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md This is a basic JSON configuration for the VS Code SFTP extension, defining connection parameters for a remote server. It includes host, port, protocol, security settings, username, remote path, and password. The `remotePath` is crucial as it specifies the directory to be downloaded or uploaded. ```json { "name": "Profile Name", "host": "name_of_remote_host", "protocol": "ftp", "port": 21, "secure": true, "username": "username", "remotePath": "/public_html/project", "password": "password", "uploadOnSave": false } ``` -------------------------------- ### SFTP: Configure Project Settings Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/commands.md Creates or modifies the SFTP configuration file for the current project. This allows users to define server connection details, paths, and other settings for SFTP operations. ```json { "command": "sftp.config" } ``` -------------------------------- ### Multiple Context SFTP Server Configurations (JSON) Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Configures different remote servers for specific local subdirectories using a JSON array. Each object in the array defines connection details and a 'context' path, allowing distinct synchronization targets for different project parts. ```json [ { "name": "Frontend Server", "context": "frontend/build", "host": "web.example.com", "username": "webuser", "password": "webpass", "remotePath": "/var/www/frontend" }, { "name": "Backend Server", "context": "backend/dist", "host": "api.example.com", "username": "apiuser", "password": "apipass", "remotePath": "/opt/api" } ] ``` -------------------------------- ### SFTP Configuration: Basic Connection Details Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/common_configuration.md Defines essential parameters for establishing an SFTP or FTP connection. This includes the server's hostname, port, username, and optionally a password for authentication. The 'name' field provides a human-readable identifier for the configuration. ```json { "name": "My Server", "host": "server.example.com", "port": 22, "username": "user1", "password": "Password123" } ``` -------------------------------- ### remotefs.remote Configuration (JSON) Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md This section demonstrates how to configure SFTP connections within the User Settings for use with the `remotefs` extension. It defines different remote environments (e.g., 'dev', 'projectX') with their respective connection parameters like scheme, host, username, and root path. ```json "remotefs.remote": { "dev": { "scheme": "sftp", "host": "host", "username": "username", "rootPath": "/path/to/somewhere" }, "projectX": { "scheme": "sftp", "host": "host", "username": "username", "privateKeyPath": "/Users/xx/.ssh/id_rsa", "rootPath": "/home/foo/some/projectx" } } ``` -------------------------------- ### SFTP: Download Files or Folders Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/commands.md Downloads specified files or folders from the SFTP server. This command accepts an array of file system paths as arguments. ```json { "command": "sftp.download", "args": ["remote/path/file1", "remote/path/folder1"] } ``` -------------------------------- ### SFTP: Upload/Download Files or Folders Source: https://github.com/natizyskunk/vscode-sftp/wiki/Commands Uploads or downloads specified file paths. This command can accept an array of strings representing local file system paths. ```javascript func(fspaths: string[]) ``` -------------------------------- ### SFTP Configuration with SSH Key Authentication (JSON) Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Sets up an SFTP connection using SSH private key authentication for enhanced security. This configuration specifies the path to the private key file and optionally a passphrase and SSH configuration file. ```json { "name": "Secure Server", "host": "secure.example.com", "protocol": "sftp", "port": 22, "username": "admin", "privateKeyPath": "/Users/username/.ssh/id_rsa", "passphrase": "key-passphrase", "remotePath": "/home/admin/project", "uploadOnSave": true, "sshConfigPath": "~/.ssh/config" } ``` -------------------------------- ### Programmatic File Service Usage (TypeScript) Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Demonstrates how to use the VSCode SFTP extension's API to programmatically manage file transfers. It shows how to retrieve an existing file service instance or create a new one with custom configuration, enabling automated uploads and other file operations within the extension. ```typescript import { FileService } from './core/fileService'; import { getFileService, createFileService } from './modules/serviceManager'; import { FileServiceConfig } from './core/fileService'; // Get existing file service for a URI: async function uploadCustomFile(fileUri: vscode.Uri) { const fileService = getFileService(fileUri); if (!fileService) { throw new Error('No SFTP configuration found'); } const config = fileService.getConfig(); const remoteFs = await fileService.getRemoteFileSystem(config); const localFs = fileService.getLocalFileSystem(); // Create transfer scheduler: const scheduler = fileService.createTransferScheduler(config.concurrency); // Perform upload: await remoteFs.upload(localPath, remotePath); } // Create new file service: const config: FileServiceConfig = { name: "Dynamic Server", host: "example.com", port: 22, username: "user", password: "pass", protocol: "sftp", remotePath: "/var/www", uploadOnSave: false, context: "/workspace", // ... other config options }; createFileService(config, workspacePath); ``` -------------------------------- ### SFTP Configuration with Multiple Contexts Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md This configuration uses an array of JSON objects to define multiple SFTP connections, each associated with a specific local 'context' (directory). This is useful for projects with different subdirectories that need to be synced to distinct remote locations. The `name` property is mandatory in this mode. ```json [ { "name": "server1", "context": "project/build", "host": "host", "username": "username", "password": "password", "remotePath": "/remote/project/build" }, { "name": "server2", "context": "project/src", "host": "host", "username": "username", "password": "password", "remotePath": "/remote/project/src" } ] ``` -------------------------------- ### Multi-Hop SFTP Configuration (JSON) Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md This configuration enables SFTP connections through multiple intermediate hosts (hops) to reach a final target server. It specifies the connection details for each hop, including host, username, and private key path, assuming keys are located on the preceding server in the chain. ```json { "name": "target", "remotePath": "/path/in/target", // hopa "host": "hopAHost", "username": "hopAUsername", "privateKeyPath": "/Users/hopAUsername/.ssh/id_rsa" // <-- The key file is assumed on the local. "hop": [ // hopb { "host": "hopBHost", "username": "hopBUsername", "privateKeyPath": "/Users/hopaUser/.ssh/id_rsa" // <-- The key file is assumed on the hopa. }, // target { "host": "targetHost", "username": "targetUsername", "privateKeyPath": "/Users/hopbUser/.ssh/id_rsa", // <-- The key file is assumed on the hopb. } ] } ``` -------------------------------- ### Download Files with VSCode SFTP Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Learn how to download remote files, folders, or entire projects to your local workspace using the VSCode SFTP extension. This can be triggered via the Command Palette, the file explorer context menu, or configured to download on file open. Programmatic download is also supported. ```typescript // Command Palette options: // - "SFTP: Download File" // - "SFTP: Download Folder" // - "SFTP: Download Project" (entire remote directory) // - "SFTP: Download Active File" // Right-click context menu in Explorer: // Select file/folder → "Download File/Folder" // Download on open (configure in sftp.json): { "downloadOnOpen": true // or "confirm" for prompt } // Programmatic usage: import { download } from './fileHandlers'; async function downloadFile(fileUri: vscode.Uri) { const ctx = await handleCtxFromUri(fileUri); await download(ctx, { ignore: null }); } ``` -------------------------------- ### SFTP Configuration with Authentication and Permissions Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/configuration.md Extends basic SFTP configuration by including password-based authentication and setting default file and directory permissions. Note the warning about storing passwords in plain text. File permissions are set using octal notation (e.g., 644 for files, 750 for directories). ```json { "name": "My Server", "protocol": "sftp", "host": "server.example.com", "port": 22, "username": "user1", "password": "Password123", "remotePath": "/", "filePerm": 644, "dirPerm": 750 } ``` -------------------------------- ### SFTP: Upload Files or Folders Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/commands.md Uploads specified files or folders to the SFTP server. This command accepts an array of file system paths as arguments. ```json { "command": "sftp.upload", "args": ["path/to/file1", "path/to/folder1"] } ``` -------------------------------- ### SFTP: Force Download (Ignore Rules) Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/commands.md Forces the download of a file, disregarding any ignore rules defined in the SFTP configuration. This ensures the file is downloaded even if it's normally excluded. ```json { "command": "sftp.forceDownload" } ``` -------------------------------- ### Remote Explorer Order Configuration (JSON) Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md This configuration snippet allows you to set the display order for items within the Remote Explorer view. By adding the `remoteExplorer.order` parameter to your `sftp.json`, you can influence how files and folders are sorted, with a default value of 0. ```json { "remoteExplorer": { "order": 1 // <-- Default value is 0. } } ``` -------------------------------- ### Enabling SFTP Debugging (VSCode Settings) Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md This instruction details how to enable debug logging for the SFTP extension in VSCode. By setting `sftp.debug` to `true` in the User Settings and reloading VSCode, detailed logs will be available in the 'sftp' output channel. ```json "sftp.debug": true ``` -------------------------------- ### SFTP: Set Profile Source: https://github.com/natizyskunk/vscode-sftp/wiki/Commands Sets the current SFTP profile. This command takes a profile name as an argument and activates that profile for subsequent operations. ```javascript func(profileName: string) ``` -------------------------------- ### SFTP Configuration: Remote Path and Permissions Source: https://github.com/natizyskunk/vscode-sftp/wiki/Common-Configuration Specifies the remote directory for file operations and sets default permissions for newly created files and directories. The `context` option allows mapping a workspace subfolder to a `remotePath`. Permissions are specified in octal format. ```json { "context": "/_subfolder_", "remotePath": "/_subfolder_", "filePerm": 644, "dirPerm": 750 } ``` -------------------------------- ### Configure Single Hop Connection via Proxy Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Establish a connection to a target server by routing through an intermediate proxy server. This 'connection hopping' feature is configured by providing details for both the proxy and the target server, including hostnames, usernames, and private key paths. The connection flow progresses from your local machine to the proxy, and then to the target server. ```json { "name": "Target Server via Proxy", "remotePath": "/var/www/target", "host": "proxy.example.com", "username": "proxyuser", "privateKeyPath": "/Users/local/.ssh/id_rsa", "hop": { "host": "target.example.com", "username": "targetuser", "privateKeyPath": "/home/proxyuser/.ssh/id_rsa" } } // Connection flow: local → proxy → target // Keys are loaded from: local machine → proxy machine ``` -------------------------------- ### Perform Multi-Select Operations in Remote Explorer Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Efficiently manage multiple remote files or folders simultaneously using multi-select capabilities within the Remote Explorer. Select items using Ctrl/Cmd-click or Shift-click to perform bulk operations such as downloading, uploading, deleting, or comparing. A context menu provides access to these bulk actions. ```typescript // In Remote Explorer view: // - Hold Ctrl/Cmd and click to select multiple files // - Hold Shift and click to select range // - Right-click on selection for context menu // Available bulk operations: // - Download multiple files/folders // - Upload to multiple locations // - Delete multiple items // - Compare multiple files // Example: Download multiple selected files // 1. Select multiple files in Remote Explorer // 2. Right-click → "Download File" // 3. All selected files download to local workspace // Note: Manual refresh may be needed after delete operations ``` -------------------------------- ### SFTP Configuration: Remote Path and Context Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/common_configuration.md Specifies the target directory on the remote server and an optional local context path. 'remotePath' is the absolute path on the server, while 'context' allows mapping a local subfolder to this remote path. ```json { "context": "/_subfolder_", "remotePath": "/_subfolder_" } ``` -------------------------------- ### SFTP: Force Download (Alt Command) Source: https://github.com/natizyskunk/vscode-sftp/wiki/Commands Forces the download of a file, disregarding any ignore rules configured for the SFTP connection. This ensures the file is downloaded even if it's typically excluded. ```plaintext Force Download ``` -------------------------------- ### SFTP Configuration with Context Mapping Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/configuration.md This configuration maps a subfolder within your local workspace to a specific path on the remote server. The `context` key specifies the local subfolder, which is then appended to the `remotePath` for all file operations. If `context` is omitted, it defaults to the workspace root. ```json { "name": "My Server", "protocol": "sftp", "host": "server.example.com", "remotePath": "/", "context": "/_subfolder_" } ``` -------------------------------- ### SFTP: Download Active File Source: https://github.com/natizyskunk/vscode-sftp/wiki/Commands Downloads the remote version of the current file and overwrites the local copy. Use this command to ensure your local file is up-to-date with the remote version. ```plaintext SFTP: Download Active File ``` -------------------------------- ### Configure Remote Explorer Download Behavior Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Settings to control how files are handled when clicked in the VSCode SFTP extension's Remote Explorer. It allows users to choose between viewing files read-only or automatically downloading them to the local system before opening. ```json // User Settings: { "sftp.downloadWhenOpenInRemoteExplorer": false } // false (default): View content read-only // true: Download file to local before opening // View-only mode (default): // - Faster file preview // - No local file created // - Read-only buffer // - Use "Edit in Local" command to download and edit // Download mode: // - Always downloads before opening // - Creates local copy immediately // - File is editable // - Changes can be uploaded ``` -------------------------------- ### SFTP Private Key Path Configuration Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/sftp_configuration.md Defines the absolute path to the user's private key file for SFTP authentication. This is a crucial setting for establishing secure connections when using key-based authentication. ```json { "privateKeyPath": "/.ssh/key.pem" } ``` -------------------------------- ### SFTP Configuration: Watcher Settings Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/common_configuration.md Configures the behavior of the watcher command, which monitors files for changes. 'watcher.files' takes glob patterns for watched files, and 'watcher.autoUpload' enables automatic uploading when changes are detected. ```json { "watcher": { "files": "src/**", "autoUpload": true } } ``` -------------------------------- ### SFTP Configuration: File and Directory Permissions Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/common_configuration.md Allows setting default octal permissions for new files and directories uploaded to the server. If not specified, the server's default permissions will be used. ```json { "filePerm": 644, "dirPerm": 750 } ``` -------------------------------- ### Configure FTP/FTPS Connection (JSON) Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Configures an FTP or secure FTP (FTPS) connection, typically used for legacy systems. This JSON snippet includes connection parameters and a 'secure' flag, with an option to disable certificate validation for troubleshooting. ```json { "name": "FTP Server", "host": "ftp.example.com", "protocol": "ftp", "port": 21, "secure": true, "username": "ftpuser", "password": "ftppass", "remotePath": "/public_html", "uploadOnSave": false, "secureOptions": { "rejectUnauthorized": false } } ``` -------------------------------- ### SFTP Connection Hopping Configuration (Single Hop) Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/README.md This JSON configuration illustrates how to set up SFTP 'connection hopping' to reach a target server through an intermediate SSH proxy server. It defines connection details for both the hop server and the final target server, including hostnames, usernames, and private key paths for authentication. This is useful for accessing servers behind firewalls or on private networks. ```json { "name": "target", "remotePath": "/path/in/target", "host": "hopHost", "username": "hopUsername", "privateKeyPath": "/Users/localUser/.ssh/id_rsa", "hop": { "host": "targetHost", "username": "targetUsername", "privateKeyPath": "/Users/hopUser/.ssh/id_rsa", } } ``` -------------------------------- ### Configure SFTP for Root Uploads Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/FAQ.md This configuration snippet provides a workaround for uploading files as the root user via SFTP. By setting `sshCustomParams` to `"sudo su -;"` in your `sftp.json`, you can attempt to elevate privileges before the SFTP session begins. Note that this method might not be universally effective and depends on server configurations. ```json "sshCustomParams": "sudo su -;" ``` -------------------------------- ### Upload on Save Configuration (JSON) Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Enables automatic uploading of files to the remote server whenever they are saved. The 'useTempFile' option can be configured for specific upload behaviors. ```json { "uploadOnSave": true, "useTempFile": false } ``` -------------------------------- ### Show Dotfiles in Remote Explorer (proftpd) Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/FAQ.md This configuration snippet demonstrates how to modify the proftpd server configuration to show dotfiles (hidden files) in the remote explorer. By changing the `ListOptions` parameter from `"-l"` to `"-la"` within the global settings of `proftpd.conf`, hidden files will become visible. ```conf #Global settings ... ListOptions "-la" ... ``` -------------------------------- ### SFTP Sync Command Options Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/configuration.md Configures the behavior of the 'Sync' command. Options include deleting extraneous files on the destination (`delete`), skipping the creation of new files (`skipCreate`), and skipping the update of existing files (`ignoreExisting`). These are useful for maintaining parity between local and remote directories. ```json { "name": "My Server", "protocol": "sftp", "host": "server.example.com", "syncOption": { "delete": true, "skipCreate": false, "ignoreExisting": false } } ``` -------------------------------- ### Configure Automatic Two-Way Sync with vscode-sftp Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/FAQ.md This JSON configuration enables automatic two-way synchronization between your local machine and a remote server using vscode-sftp. It utilizes a watcher to monitor file changes and sync them automatically. Ensure `uploadOnSave` is set to `false` if `watcher.autoUpload` is `true` and `files` is set to '**/*'. The `syncOption.delete` parameter ensures that extraneous files on the destination are removed. ```json { "name": "My Server", "host": "", "protocol": "sftp", "port": 22, "username": "user1", "remotePath": "/folder1/folder2/folder3", "uploadOnSave": false, "watcher": { "files": "**/*", "autoUpload": true, "autoDelete": true }, "syncOption": { "delete": true } } ``` -------------------------------- ### SFTP: Download Active Folder Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/commands.md Downloads the entire folder containing the currently active file from the remote SFTP server. This allows for local backup or offline work. ```json { "command": "sftp.downloadActiveFolder" } ``` -------------------------------- ### SFTP Configuration with Download on Open Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/configuration.md This setting automatically downloads a file from the remote SFTP server whenever that file is opened within VS Code. This ensures that the local version is always the most up-to-date. It requires manual configuration for each file or project. ```json { "name": "My Server", "protocol": "sftp", "host": "server.example.com", "port": 22, "username": "user1", "downloadOnOpen": true } ``` -------------------------------- ### Enable VSCode SFTP Debug Logging Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Configuration settings for enabling debug logging in the VSCode SFTP extension. This is crucial for troubleshooting connection and transfer issues by providing detailed output in the Output panel. It includes instructions on how to enable/disable logging and what information to expect in the debug logs. ```json // User Settings (settings.json): { "sftp.debug": true, "sftp.printDebugLog": true } // View logs: // 1. Open Output panel (View > Output) // 2. Select "sftp" from dropdown // Debug output includes: // - Connection establishment details // - Authentication process // - File transfer operations // - SSH/FTP protocol messages // - Error stack traces // - Performance metrics // Example debug output: /* [INFO] Connecting to example.com:22 [DEBUG] Parser: authentication successful [DEBUG] Client: channel opened [DEBUG] Client: upload /local/file.js -> /remote/file.js [INFO] Upload complete: file.js (1.2 KB) */ // Disable after troubleshooting: { "sftp.debug": false } ``` -------------------------------- ### Configure SFTP Algorithms for Legacy Systems Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/FAQ.md This configuration overrides the default transport layer algorithms to resolve connection issues with legacy SFTP systems. It explicitly removes the 'diffie-hellman-group-exchange-sha256' algorithm from the key exchange process. Ensure this JSON is placed in your 'sftp.json' configuration file. ```json { "algorithms": { "kex": [ "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521" ], "cipher": [ "aes128-gcm", "aes128-gcm@openssh.com", "aes256-gcm", "aes256-gcm@openssh.com", "aes128-cbc", "aes192-cbc", "aes256-cbc", "aes128-ctr", "aes192-ctr", "aes256-ctr" ], "serverHostKey": [ "ssh-rsa", "ssh-dss", "ssh-ed25519", "ecdsa-sha2-nistp256", "ecdsa-sha2-nistp384", "ecdsa-sha2-nistp521", "rsa-sha2-256", "rsa-sha2-512" ], "hmac": [ "hmac-sha2-256", "hmac-sha2-512" ] } } ``` -------------------------------- ### SFTP Interactive Authentication Configuration Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/sftp_configuration.md Enables the keyboard-interactive authentication mechanism, useful for multi-factor authentication like Google Authenticator. It can be set to 'true' to enable a 'verifyCode' dialog or an array of predefined phrases for automatic input. ```json { "interactiveAuth": true } ``` -------------------------------- ### SFTP: Force Upload (Alt Command) Source: https://github.com/natizyskunk/vscode-sftp/wiki/Commands Forces the upload of a file, ignoring any configured ignore rules. This command is useful for uploading files that might otherwise be skipped due to exclusion settings. ```plaintext Force Upload ``` -------------------------------- ### SFTP: Download Current File Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/commands.md Downloads the remote version of the currently active file and overwrites the local copy. This is useful for synchronizing changes from the server. ```json { "command": "sftp.downloadActiveFile" } ``` -------------------------------- ### Configure SFTP Multiple Hop Connections Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Chain multiple proxy servers to reach the target SFTP server. This configuration allows connections to pass through intermediate hosts, each using keys from the previous machine. Variable substitution is not supported within hop configurations. ```json { "name": "Target via Multiple Hops", "remotePath": "/app/target", "host": "hop1.example.com", "username": "hop1user", "privateKeyPath": "/Users/local/.ssh/id_rsa", "hop": [ { "host": "hop2.example.com", "username": "hop2user", "privateKeyPath": "/home/hop1user/.ssh/id_rsa" }, { "host": "target.example.com", "username": "targetuser", "privateKeyPath": "/home/hop2user/.ssh/id_rsa", "password": "fallback-password" } ] } // Connection flow: local → hop1 → hop2 → target // Each hop uses keys from the previous machine // Variable substitution is NOT available in hop configurations ``` -------------------------------- ### SFTP: Upload Active Folder Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/commands.md Uploads the entire folder containing the currently active file to the remote SFTP server. This is useful for deploying entire project directories. ```json { "command": "sftp.uploadActiveFolder" } ``` -------------------------------- ### Enable SFTP Temporary File Uploads Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Configure the extension to use temporary files for uploads, ensuring atomicity. Files are uploaded to a temporary name first and then renamed upon successful completion, preventing partial files from being served. This is ideal for high-traffic or critical production environments. ```json { "host": "production.example.com", "username": "deploy", "remotePath": "/var/www/html", "uploadOnSave": true, "useTempFile": true, "openSsh": false } // How it works: // 1. File uploads as "filename.tmp" // 2. Complete upload verified // 3. Atomic rename to actual filename // 4. Prevents serving partial content during upload // Use cases: // - High-traffic production servers // - Large files that take time to upload // - Critical files that must be complete ``` -------------------------------- ### Implement Custom SFTP Transfer Logic in TypeScript Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt This TypeScript code demonstrates how to implement a custom file transfer handler for uploading local files to a remote SFTP server using VSCode SFTP's core modules. It configures transfer options such as ignore patterns and temporary files, and uses a scheduler to manage the transfer tasks. Dependencies include core modules for file transfer, filesystem abstraction, and scheduling. ```typescript import { transfer, sync, TransferDirection } from './fileHandlers/transfer/transfer'; import { FileSystem, SFTPFileSystem } from './core/fs'; import Scheduler from './core/scheduler'; async function customTransfer( localPath: string, remotePath: string, fileService: FileService ) { const config = fileService.getConfig(); const remoteFs = await fileService.getRemoteFileSystem(config); const localFs = fileService.getLocalFileSystem(); const scheduler = fileService.createTransferScheduler(4); // Configure transfer: await transfer( { srcFsPath: localPath, srcFs: localFs, targetFsPath: remotePath, targetFs: remoteFs, transferOption: { ignore: config.ignore, useTempFile: true, perserveTargetMode: false }, filePerm: 644, dirPerm: 755, transferDirection: TransferDirection.LOCAL_TO_REMOTE }, task => scheduler.add(task) ); await scheduler.run(); } ``` -------------------------------- ### SFTP Transport Layer Algorithms Configuration Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/sftp_configuration.md Allows explicit overrides for the default transport layer algorithms (kex, cipher, serverHostKey, hmac) used during the SFTP connection. This provides fine-grained control over the security protocols employed. ```json { "algorithms": { "kex": [ "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "diffie-hellman-group-exchange-sha256" ], "cipher": [ "aes128-gcm", "aes128-gcm@openssh.com", "aes256-gcm", "aes256-gcm@openssh.com", "aes128-cbc", "aes192-cbc", "aes256-cbc", "aes128-ctr", "aes192-ctr", "aes256-ctr" ], "serverHostKey": [ "ssh-rsa", "ssh-dss", "ssh-ed25519", "ecdsa-sha2-nistp256", "ecdsa-sha2-nistp384", "ecdsa-sha2-nistp521", "rsa-sha2-512", "rsa-sha2-256" ], "hmac": [ "hmac-sha2-256", "hmac-sha2-512" ] } } ``` -------------------------------- ### SFTP Agent Path Configuration Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/sftp_configuration.md Specifies the path to the ssh-agent's UNIX socket for user authentication. For Windows, it can be set to 'pageant' or the path to a Cygwin UNIX socket. This setting enhances stability by adhering to potential client/server limits. ```json { "agent": "/_subfolder_/agent" } ``` -------------------------------- ### SFTP Configuration: Ignore Patterns Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/common_configuration.md Specifies files and folders to be ignored during synchronization, similar to gitignore. Supports wildcards and paths relative to the current configuration's context. ```json { "ignore": [ "/.vscode", "/.git", "/.cache", "/_subfolder_", ".DS_Store", "*.gz", "*.log" ] } ``` -------------------------------- ### SFTP Configuration: Download on Open Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/common_configuration.md Determines whether files are downloaded from the remote server automatically whenever they are opened in VSCode. This ensures you are always working with the latest version on the server. ```json { "downloadOnOpen": true } ``` -------------------------------- ### SFTP: Download Active Folder Source: https://github.com/natizyskunk/vscode-sftp/wiki/Commands Downloads the entire folder containing the current file from the remote SFTP server. This operation replaces the local folder with the remote one. ```plaintext SFTP: Download Active Folder ``` -------------------------------- ### Synchronize Directories with VSCode SFTP Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Synchronize local and remote directories using various strategies. The extension supports syncing from local to remote, remote to local, or in both directions. Configuration options include deleting files not present in the source, skipping file creation or existing files, and updating modified files. ```typescript // Command Palette options: // - "SFTP: Sync Local -> Remote" // - "SFTP: Sync Remote -> Local" // - "SFTP: Sync Both Directions" // Configuration for sync behavior: { "syncOption": { "delete": true, // Delete files not in source "skipCreate": false, // Skip creating new files "ignoreExisting": false, // Skip existing files "update": true // Update modified files only } } // Programmatic usage: import { sync2Remote, sync2Local } from './fileHandlers'; async function syncToRemote(folderUri: vscode.Uri) { const ctx = await handleCtxFromUri(folderUri); await sync2Remote(ctx); } // Example sync with custom options: await sync2Remote(ctx, { delete: true, update: true, ignoreExisting: false, skipCreate: false }); ``` -------------------------------- ### SFTP SSH Configuration Path Configuration Source: https://github.com/natizyskunk/vscode-sftp/blob/develop/docs/sftp_configuration.md Specifies the absolute path to the user's SSH configuration file. The default path is `~/.ssh/config`. This allows customization of SSH client behavior for SFTP connections. ```json { "sshConfigPath": "~/.ssh/config" } ``` -------------------------------- ### Diff Local and Remote Files with VSCode SFTP Source: https://context7.com/natizyskunk/vscode-sftp/llms.txt Compare local files with their remote counterparts directly within VS Code. This feature utilizes VS Code's built-in diff viewer, presenting the remote file on the left and the local file on the right. It can be invoked from the Command Palette or the file explorer's context menu. ```typescript // Command Palette: // - "SFTP: Diff with Remote" // - "SFTP: Diff Active File with Remote" // Right-click context menu: // Select file → "Diff with Remote" // This opens VS Code's diff viewer showing local vs remote changes // Left side: Remote file // Right side: Local file // Configuration example: { "host": "example.com", "username": "user", "remotePath": "/var/www" } // The diff command automatically handles: // - Temporary file creation for remote content // - Side-by-side comparison view // - Syntax highlighting for both versions ``` -------------------------------- ### Configure SFTP TLS Connection Options (JSON) Source: https://github.com/natizyskunk/vscode-sftp/wiki/FTP(s)-only-Configuration Provides additional options to be passed to the Node.js 'tls.connect()' function for establishing secure TLS connections. This allows for fine-grained control over the TLS handshake process. ```json { "secureOptions": { "enableTrace": true } } ```