Skip to content

feat: stabilize SFTP and add secure SSH terminal integration - #2694

Open
bajrangCoder wants to merge 3 commits into
mainfrom
feat/sftp-improvements
Open

feat: stabilize SFTP and add secure SSH terminal integration#2694
bajrangCoder wants to merge 3 commits into
mainfrom
feat/sftp-improvements

Conversation

@bajrangCoder

Copy link
Copy Markdown
Member

Summary

This PR improves the reliability and security of Acode's SFTP integration and adds interactive SSH terminal support using the existing Maverick Synergy SSH library.

It addresses the SFTP lifecycle, cleanup, and path issues reported in:

SFTP reliability improvements

  • Prevent overlapping SFTP connection attempts.
  • Properly close previous SFTP and SSH connections before switching servers.
  • Reduce Maverick SFTP window sizes and asynchronous request limits for Android.
  • Improve handling of disconnected and partially initialized sessions.
  • Clean up SFTP files, folders, recents, and active editor references when a storage is removed.
  • Preserve URL path boundaries when removing or comparing remote entries.
  • Improve private-key and connection error handling.

SSH terminal integration

  • Add interactive SSH terminal sessions using Maverick SessionChannelNG.
  • Allocate an xterm-256color PTY and start an interactive remote shell.
  • Stream binary terminal output safely through the Cordova bridge.
  • Support password and private-key authentication.
  • Forward terminal input in order through a per-session native writer.
  • Synchronize terminal dimensions with the remote PTY.
  • Handle exit codes, connection errors, intentional closes, and plugin lifecycle cleanup.
  • Keep terminal connections independent from the global SFTP browser connection.
  • Add “Open SSH Terminal” to saved SFTP storage and open-folder context menus.
  • Prevent remote hosts from invoking Acode's local OSC 7777 file-opening protocol.
  • Keep remote-terminal creation internal; it is not exposed through the public Acode plugin API.

Secure SFTP profiles

Previously, SFTP URLs could contain usernames, passwords, key-file paths, and passphrases.

This PR replaces persisted connection URLs with opaque identifiers:

sftp://profile-<uuid>/remote/path

The corresponding connection profile is stored natively and encrypted using:

  • Android Keystore-managed AES key
  • AES/GCM/NoPadding
  • Random IV per profile encryption
  • Profile ID as authenticated additional data

Encrypted profiles contain the server details and authentication material. Profile reads exposed to JavaScript return metadata only and never return passwords, passphrases, or private-key contents.

Private-key files selected for new profiles are read by the native plugin and stored inside the encrypted profile instead of being copied into an SFTP URL.

Migration

On startup, legacy SFTP URLs are migrated across:

  • Saved storages
  • Remembered files
  • Remembered folders
  • Recent files
  • Recent folders
  • File-browser state

Migration behavior is intentionally conservative:

  • Repeated URLs using the same credentials reuse the migrated profile.
  • Paths are preserved while credentials and query parameters are removed.
  • A failed profile migration leaves the legacy URL unchanged.
  • App-private plaintext key copies are removed only after successful migration.
  • Shared profiles are not deleted while another saved storage still references them.

@github-actions github-actions Bot added the enhancement New feature or request label Aug 8, 2026
@bajrangCoder
bajrangCoder marked this pull request as ready for review August 8, 2026 03:27
@UnschooledGamer UnschooledGamer added the S/FTP Issues and Pull requests related to SFTP/FTP. label Aug 8, 2026
@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves SFTP credentials from persisted URLs into encrypted native profiles, strengthens SFTP connection and cleanup behavior, and adds interactive SSH terminal sessions backed by Maverick Synergy.

  • Migrates saved SFTP references to opaque profile URLs before restoring application state.
  • Adds encrypted profile and known-host storage using Android Keystore-backed AES-GCM.
  • Adds independent SSH shell sessions with binary output streaming, ordered input, PTY resizing, host-key handling, and lifecycle cleanup.
  • Updates storage, recents, folder, URL, and file-browser handling for profile-based SFTP paths.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified.

The migration preserves legacy references when profile creation fails, profile-backed URLs retain remote paths, and native SSH sessions have isolated clients with idempotent lifecycle cleanup.

Important Files Changed

Filename Overview
src/plugins/sftp/src/com/foxdebug/sftp/Sftp.java Adds encrypted-profile connections, host-key verification, tuned SFTP behavior, and independently managed interactive SSH shell sessions.
src/plugins/sftp/src/com/foxdebug/sftp/SftpSecurityStore.java Implements Android Keystore-backed AES-GCM storage for connection profiles and persisted host keys.
src/lib/sftpProfiles.js Migrates credential-bearing SFTP URLs across persisted application state while preserving paths and retaining legacy values after migration failures.
src/fileSystem/sftp.js Adds profile-backed authentication and serializes connection attempts while retaining automatic reconnection behavior.
src/components/terminal/terminal.js Connects xterm to native SSH shells and handles streaming output, input, resizing, host verification, exit events, and teardown.
src/components/terminal/terminalManager.js Adds internal creation and lifecycle management for SSH terminals without persisting them as local terminal sessions.
src/pages/fileBrowser/fileBrowser.js Adds SSH terminal actions and coordinates profile-aware cleanup when saved remote storage is removed.
src/utils/Url.js Updates URL handling to preserve profile URL path boundaries, covered by focused unit tests.
src/main.js Runs SFTP profile migration before restored files, folders, recents, and browser state are consumed.

Sequence Diagram

sequenceDiagram
  participant App as Acode startup
  participant Migration as SFTP profile migration
  participant Store as Native encrypted store
  participant FS as SFTP filesystem
  participant Terminal as SSH terminal
  participant Server as Remote SSH server

  App->>Migration: Migrate persisted legacy SFTP URLs
  Migration->>Store: Encrypt and save credentials/key material
  Store-->>Migration: profile-UUID
  Migration-->>App: Replace URLs with sftp://profile-UUID/path
  App->>FS: Restore files and folders
  FS->>Store: Load profile internally
  FS->>Server: Open SFTP connection

  App->>Terminal: Open SSH terminal for profile
  Terminal->>Store: Request profile-backed shell
  Store->>Server: Authenticate and allocate PTY
  Server-->>Terminal: ready / binary data / exit events
  Terminal->>Server: Ordered input and resize events
Loading

Reviews (1): Last reviewed commit: "feat(sftp): secure profiles and verify h..." | Re-trigger Greptile

RohitKushvaha01

This comment was marked as outdated.

@@ -0,0 +1,160 @@
package com.foxdebug.sftp;

@RohitKushvaha01 RohitKushvaha01 Aug 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have used the EncryptedPreferences class instead of using normal SharedPref

(you can import classes and stuff from oher plugins without errors)

@UnschooledGamer UnschooledGamer added the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Aug 8, 2026
@github-actions github-actions Bot removed the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Aug 8, 2026
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Preview Release for this, has been built.

Click here to view that github actions build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request S/FTP Issues and Pull requests related to SFTP/FTP.

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

The app crashes when loading SFTP files Deleted SFTP folders still tries reconnect

3 participants