Ashari Abidin's Developer Docs

Termux Complete Short Guide

๐Ÿ“ก SCP ยท Secure Copy Protocol

Complete Guide to using SCP in Termux (Android) โ€” Every command explained in English.

Encrypted file transfer between your Android device (Termux) and remote servers.

1. Overview

scp (Secure Copy Protocol) is a command-line tool that allows you to securely transfer files and directories between your Android device (using Termux) and a remote server over SSH.

๐Ÿ“Œ Common use cases:

  • Upload project files from Android to a Linux server.
  • Download files from a server to Android.
  • Backup files between devices.

2. Prerequisites & Installation

๐Ÿ”ง Step 1: Install OpenSSH in Termux

pkg update && pkg install openssh
๐Ÿ“ Explanation: Updates Termux package repositories and installs OpenSSH, which provides the scp, ssh, and related commands.
scp -V
๐Ÿ” Explanation: Displays the installed SCP version to verify OpenSSH is correctly installed.
which scp
๐Ÿ“ Explanation: Shows the location of the scp binary file (e.g., /data/data/com.termux/files/usr/bin/scp).

๐Ÿ” Step 2: Verify SSH Access

ssh ubuntu@115.178.135.124
๐ŸŒ Explanation: Attempts to log into the remote server as user ubuntu at the given IP. If SSH works, SCP will work as well.
โœ… Note: SCP uses the same authentication and connection as SSH, so a successful SSH login is required.

3. Basic SCP Syntax

scp [options] source destination
๐Ÿ“– Structure: source = file/folder to copy from, destination = target location. Options like -r, -P, etc., modify behavior.
scp file.txt user@server:/path/
โฌ†๏ธ Upload: Sends file.txt from your local machine to /path/ on the remote server.
scp user@server:/path/file.txt .
โฌ‡๏ธ Download: Retrieves file.txt from the server and saves it in the current local directory (denoted by .).

4. Uploading Files from Android to a Server

๐Ÿ“ Single file

scp /storage/emulated/0/Download/app.zip ubuntu@115.178.135.124:/home/ubuntu/
๐Ÿ“ฆ Explanation: Copies app.zip from Android's Download folder to the Ubuntu user's home directory on the remote server.

๐Ÿ“‚ Multiple files

scp file1.txt file2.txt file3.txt ubuntu@115.178.135.124:/home/ubuntu/
๐Ÿ“‘ Explanation: Sends three files at once to the server in a single command.

5. Uploading Directories (Recursive)

scp -r /storage/emulated/0/Download/regapicta ubuntu@115.178.135.124:/home/ubuntu/upload/
๐Ÿ—‚๏ธ Explanation: The -r (recursive) flag uploads the entire regapicta folder and all its contents to /home/ubuntu/upload/ on the server.

6. Downloading Files from a Server to Android

โฌ‡๏ธ Download to current directory

scp ubuntu@115.178.135.124:/home/ubuntu/app.zip .
๐Ÿ“ฅ Explanation: Downloads app.zip from the server and stores it in Termux's current working directory.

๐Ÿ“€ Download to Android Download folder

scp ubuntu@115.178.135.124:/home/ubuntu/app.zip /storage/emulated/0/Download/
๐Ÿ“ฒ Explanation: The file is saved directly to Android's internal storage Download folder, making it accessible by other apps.

7. Downloading Directories (Recursive)

scp -r ubuntu@115.178.135.124:/home/ubuntu/project /storage/emulated/0/Download/
๐Ÿ“ Explanation: Downloads the entire project folder from the server (including all subdirectories) to Android's Download folder.

8. Using a Custom SSH Port

โš ๏ธ Important: scp uses uppercase -P (not lowercase -p).
scp -P 2222 app.zip ubuntu@115.178.135.124:/home/ubuntu/
๐Ÿ”Œ Explanation: Specifies port 2222 for the SSH connection (default is 22). Useful when the server listens on a non-standard port.

9. Using SSH Keys (Passwordless & Secure)

scp -i ~/.ssh/id_rsa app.zip ubuntu@115.178.135.124:/home/ubuntu/
๐Ÿ”‘ Explanation: -i specifies a private key file (e.g., id_rsa) for authentication. More secure and avoids password prompts.
scp -i ~/.ssh/id_rsa ubuntu@115.178.135.124:/home/ubuntu/app.zip .
๐Ÿ” Explanation: Downloads a file from the server using key-based authentication. Ideal for automated scripts.

10. Viewing Transfer Progress (Verbose Mode)

scp -v app.zip ubuntu@115.178.135.124:/home/ubuntu/
๐Ÿž Explanation: -v (verbose) prints detailed connection steps, SSH negotiation, and transfer progress โ€” excellent for debugging.
scp -rv project ubuntu@115.178.135.124:/home/ubuntu/
๐Ÿ“ข Explanation: Combines -r (recursive) with -v (verbose) for full logging of directory transfers.

11. Compression During Transfer (Faster Transfers)

scp -rC project ubuntu@115.178.135.124:/home/ubuntu/
๐Ÿ—œ๏ธ Explanation: The -C flag enables on-the-fly compression, reducing bandwidth usage and speeding up transfers of large folders.

12. Accessing Android Storage in Termux

termux-setup-storage
๐Ÿ“‚ Explanation: One-time command to grant Termux access to Android's shared storage. Creates the symlink /storage/emulated/0.
cd /storage/emulated/0/Download
๐Ÿ“ Explanation: Navigates to the internal Download directory, a common location for files to upload.
LocationPath
๐Ÿ“ฑ Internal Storage/storage/emulated/0
๐Ÿ“ฅ Download/storage/emulated/0/Download
๐Ÿ“ธ DCIM/storage/emulated/0/DCIM
๐Ÿ–ผ๏ธ Pictures/storage/emulated/0/Pictures
๐Ÿ“„ Documents/storage/emulated/0/Documents

13. Real-World Examples

๐Ÿ“ฆ Upload Regapicta Project

scp -r /storage/emulated/0/Download/regapicta ubuntu@115.178.135.124:/home/ubuntu/upload/
๐Ÿš€ Explanation: Sends a development project folder from Android to a dedicated upload directory on the server.

๐Ÿ“„ Upload requirements.txt

scp requirements.txt ubuntu@115.178.135.124:/home/ubuntu/upload/
๐Ÿ Explanation: Transfers a Python dependencies file to the server for application deployment.

๐Ÿ Upload Flask Application

scp -r flask_app ubuntu@115.178.135.124:/home/ubuntu/apps/
๐ŸŒ Explanation: Uploads an entire Flask web app directory to the server's apps folder.

๐Ÿ“ฅ Download OCR Results

scp ubuntu@115.178.135.124:/home/ubuntu/output.json /storage/emulated/0/Download/
๐Ÿ“„ Explanation: Fetches a JSON results file from the server and saves it to Android's Download folder.

14. Troubleshooting & Solutions

๐Ÿ”’ Permission Denied

ssh ubuntu@115.178.135.124
๐Ÿ” Explanation: Test SSH connectivity first. If SSH fails, SCP will also fail. Check username, keys, or server permissions.

๐Ÿ“‚ No Such File or Directory

ls -la /path/expected
๐Ÿ“ Explanation: Verify that the source or destination path exists. Use ls to confirm file/folder presence.

๐Ÿšซ Connection Refused

๐Ÿ›ก๏ธ Possible causes: SSH service not running on server, wrong port, or firewall blocking. On the server, check with sudo systemctl status ssh.

โฑ๏ธ Timeout

ping 115.178.135.124
๐Ÿ“ก Explanation: Check network connectivity. If ping fails, verify IP address, internet connection, or ISP restrictions.

15. Recommended Workflow (Android โ†’ Ubuntu Server)

  1. ssh ubuntu@115.178.135.124 โ†’ Test connection
  2. scp -r regapicta ubuntu@115.178.135.124:/home/ubuntu/upload/ โ†’ Upload project
  3. ssh ubuntu@115.178.135.124 โ†’ Log into server
  4. cd /home/ubuntu/upload && ls -la โ†’ Verify upload
  5. cd regapicta && python -m venv venv && source venv/bin/activate && pip install -r requirements.txt โ†’ Deploy application

โšก Cheatsheet with Explanations

๐Ÿ“ค Upload file
scp file.txt user@server:/path/
Copy local file to remote server
๐Ÿ“ Upload folder
scp -r folder user@server:/path/
Recursive copy of entire directory
๐Ÿ“ฅ Download file
scp user@server:/path/file.txt .
Save remote file to current local directory
๐Ÿ—‚๏ธ Download folder
scp -r user@server:/path/folder .
Download directory recursively
๐Ÿ”Œ Custom port
scp -P 2222 file.txt user@server:/path/
Specify SSH port (uppercase P)
๐Ÿ”‘ SSH key
scp -i ~/.ssh/id_rsa file.txt user@server:/path/
Authenticate using private key
๐Ÿ—œ๏ธ Compression
scp -rC folder user@server:/path/
Enable compression for speed
๐Ÿž Verbose debug
scp -v file.txt user@server:/path/
See detailed transfer logs
๐Ÿ’ก Key takeaway: Every SCP command follows the pattern source โ†’ destination, with options for recursion, port changes, key authentication, or compression.

โšก Complete SCP guide with explanations for every command โ€” perfect for Termux on Android.
#SCPonTermux #RedGuide #EnglishExplanations

Back