Skip to content

SSH & SFTP

Connecting to remote machines, managing keys, tunnelling ports and moving files securely. Real OpenSSH client commands — the same ones you would type on a laptop to reach a server, Raspberry Pi or VPS from your phone.

Print or save this page for offline reference.

Connecting

CommandDescription
ssh user@hostOpen a shell on a remote host.
ssh -p 2222 user@hostConnect on a non-default port.
ssh -i key.pem user@hostAuthenticate with a specific private key.
ssh user@host 'cmd'Run a single command remotely and exit.

Keys

CommandDescription
ssh-keygen -t ed25519Generate a modern Ed25519 key pair.
ssh-copy-id user@hostInstall your public key on the server.
ssh-add keyLoad a private key into the SSH agent.
chmod 600 ~/.ssh/id_ed25519Lock down key permissions (required by SSH).

Tunnels & forwarding

CommandDescription
ssh -L 8080:localhost:80 hostLocal forward: reach a remote port locally.
ssh -R 9000:localhost:3000 hostRemote forward: expose a local port on the server.
ssh -D 1080 hostDynamic SOCKS proxy over the SSH connection.
ssh -N -f hostOpen a tunnel in the background, no shell.

Config & agent

CommandDescription
~/.ssh/configPer-host settings: Host, HostName, User, Port, IdentityFile.
ssh -v user@hostVerbose output to debug a failing connection.
ServerAliveInterval 60Keep-alive setting to stop idle disconnects.
ssh-add -lList keys currently loaded in the agent.

SFTP & file transfer

CommandDescription
sftp user@hostOpen an interactive secure file-transfer session.
put localfileUpload a file to the remote host (inside sftp).
get remotefileDownload a file from the remote host.
scp file user@host:/pathCopy a file to a remote path in one command.
rsync -avz src/ host:dst/Sync directories efficiently, only changed data.

Put this to work on Android with the Terminal & SSH.