Skip to content

Linux sftp Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux sftp Guide

Complete beginner-friendly guide to sftp on Linux, covering Arch Linux, CachyOS, and other distributions including secure file transfer protocol, interactive file operations, and remote file management.


Table of Contents

  1. sftp Basics
  2. Interactive Mode
  3. sftp Commands
  4. Batch Mode
  5. Troubleshooting

sftp Basics

Connect to Server

Basic usage:

# Connect to server
sftp user@server

# Opens interactive sftp session

With Custom Port

Non-standard port:

# Custom SSH port
sftp -P 2222 user@server

# -P = port (capital P for sftp)

Interactive Mode

Basic Commands

Common commands:

# In sftp:
# ls          - List remote files
# lls         - List local files
# cd          - Change remote directory
# lcd         - Change local directory
# pwd         - Print remote working directory
# lpwd        - Print local working directory

File Operations

Transfer files:

# In sftp:
# get file.txt        - Download file
# put file.txt        - Upload file
# get -r directory/    - Download directory
# put -r directory/    - Upload directory

sftp Commands

Download Files

Get files:

# In sftp:
# get file.txt
# get file.txt local_name.txt
# get -r directory/

Upload Files

Put files:

# In sftp:
# put file.txt
# put file.txt remote_name.txt
# put -r directory/

Batch Mode

Batch File

Automated transfer:

# Create batch file
echo "get file.txt" > batch.txt
echo "put local.txt" >> batch.txt

# Run batch
sftp -b batch.txt user@server

# -b = batch (executes commands from file)

Troubleshooting

Connection Failed

Check SSH:

# Test SSH connection
ssh user@server

# Ensure SSH works first

Permission Denied

Check permissions:

# On server, check directory permissions
ls -la /path/to/directory

Summary

This guide covered sftp usage, secure file transfer, and remote file management for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally