Skip to content

Add interactive session management with SSH/SFTP/FTP commands#7

Merged
VectoDE merged 3 commits intomainfrom
codex/prepare-servercommander-for-enterprise-production
Oct 21, 2025
Merged

Add interactive session management with SSH/SFTP/FTP commands#7
VectoDE merged 3 commits intomainfrom
codex/prepare-servercommander-for-enterprise-production

Conversation

@VectoDE
Copy link
Owner

@VectoDE VectoDE commented Oct 21, 2025

Summary

  • replace the fixed command switch with a registry-driven dispatcher and reusable helper utilities
  • add persisted session management plus SSH, SFTP and FTP sub-commands that wrap system clients and a custom FTP implementation
  • enhance logging, configuration storage and documentation to describe the interactive workflow

Testing

  • go build ./...

https://chatgpt.com/codex/tasks/task_e_68f757587ce8832cb8ce5a4a55e348c0

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +64 to +95
func runSFTPBatch(alias string, commands []string, postProcess func(string) error) error {
session, err := loadSession(alias)
if err != nil {
return err
}
if session.Protocol != config.ProtocolSFTP {
return fmt.Errorf("session '%s' is not configured for SFTP", session.Alias)
}

password, err := promptPassword(session)
if err != nil {
return err
}

batch := strings.Join(commands, "\n") + "\n"
args := buildSFTPArgs(session)
cmd := exec.Command("sftp", args...)
cmd.Stdin = strings.NewReader(batch)
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr

if password != "" {
fmt.Println(utils.Yellow, "Note: Enter the password when prompted by sftp.", utils.Reset)
}

if err := cmd.Run(); err != nil {
output := stderr.String()
if output == "" {
output = stdout.String()
}
return fmt.Errorf("sftp command failed: %s", strings.TrimSpace(output))

Choose a reason for hiding this comment

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

P1 Badge Batch SFTP has no way to provide passwords

The new SFTP commands always run sftp in batch mode with cmd.Stdin set to the command script and both Stdout/Stderr captured into buffers. For sessions that use password authentication, promptPassword asks the user for a password but the value is never forwarded to the spawned sftp process, nor is the process attached to the terminal so it can prompt on its own. As a result, any password-protected SFTP session will fail (or hang) because sftp cannot read the password. Only key-based sessions work. When RequiresPass is true, STDIN/STDOUT should remain attached to the terminal and the collected password should be supplied (e.g. via sshpass or by letting sftp prompt directly).

Useful? React with 👍 / 👎.

@VectoDE VectoDE merged commit 83da055 into main Oct 21, 2025
1 check passed
@VectoDE VectoDE deleted the codex/prepare-servercommander-for-enterprise-production branch October 21, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant