Locionic
Blog
Projects
Dev ToolsCheatsheetsSeries & Guides
About MeFree Production KitContact
Send email to LocionicLocionic GitHub profileLocionic YouTube channel
© 2026Locionic• All rights reserved.
Dev Kits & Data•Tools•Tags•RSS•Privacy Policy•Terms
  1. Home
  2. Blog
  3. SSH and SCP: The Two Tools Every Developer Should Actually Understand
Monday, March 23, 2026•7 min read

SSH and SCP: The Two Tools Every Developer Should Actually Understand

Locionic
Locionic(@Locionic)
linux devops security terminal networking
SSH and SCP: The Two Tools Every Developer Should Actually Understand

If you've spent any time working with servers, you've likely typed ssh into a terminal without thinking too hard about it. But when you get locked out at 2 AM or file transfers keep failing, knowing the mechanics of SSH (Secure Shell) and SCP (Secure Copy Protocol) becomes invaluable.

Audio Briefing• Voice: Google Cloud Journey-F
0:00 / --:--
What Even Is SSH?

SSH allows you to log into a remote computer and run commands securely. Before SSH, tools like Telnet transmitted everything - including passwords - in plain text. SSH fixed this by encrypting the entire session.

Port 22 and Connectivity

By default, SSH connects over port 22. It's a "well-known port" reserved for system services. While you can't hide from determined attackers, moving SSH to a non-standard port (like 2222) dramatically reduces automated brute-force attempts.

To connect to a custom port:

bash
ssh -p 2222 user@yourserver.com

Level Up Your SSH Workflow

Stop Typing Passwords (Use SSH Keys)

Passwords are slow and insecure. Generate an Ed25519 key pair (it's faster and more secure than RSA):

bash
ssh-keygen -t ed25519 -C "your_email@example.com"

Copy the public key to your server. From then on, you log in securely and instantly.

bash
ssh-copy-id user@yourserver.com

Configure Your SSH Profile

Stop memorizing IP addresses and ports. Create an SSH config file (~/.ssh/config) to create clean aliases for your servers.

text
Host myserver
    HostName 192.168.1.100
    User alice
    Port 2222
    IdentityFile ~/.ssh/id_ed25519

Now, connecting is as simple as typing:

bash
ssh myserver

Transfer Files Securely with SCP

SCP uses SSH under the hood to transfer files between machines. The syntax is simply scp source destination.

Copy to a server:

bash
scp myfile.txt myserver:/home/alice/

Copy from a server (note the trailing ./):

bash
scp myserver:/home/alice/myfile.txt ./
Capital P for SCP Ports

While SSH uses a lowercase -p for custom ports, SCP uses a capital -P. scp -P 2222 myfile.txt user@server:/path/

SCP vs. The Alternatives

SCP is fantastic for quick file transfers, but it isn't always the best tool for the job.

  • rsync: The ultimate tool for syncing directories. It only transfers changed delta blocks, making it drastically faster for large directories. (e.g., rsync -avzP local/ myserver:/remote/)
  • SFTP: A robust subsystem running over SSH that lets you interactively browse, seek, rename, and resume interrupted file transfers.
FeatureSCPrsyncSFTP
Directory Resumption❌ No✅ Yes (--partial)✅ Yes
Delta Compression❌ Whole files✅ Block-level diffs❌ Whole files
Interactive Navigation❌ No❌ No✅ Yes
Standard Availability✅ Everywhere⚠️ Needs rsync on remote✅ Everywhere

SSH Tunneling & Port Forwarding

SSH can tunnel arbitrary TCP traffic through an encrypted pipe, allowing you to access private databases or bypass firewalls safely:

1. Local Port Forwarding (-L)

Forward a port on your local machine to a remote internal database that isn't publicly exposed:

bash
# Connect local localhost:5432 to private RDS instance 10.0.1.25:5432 via bastion
ssh -L 5432:10.0.1.25:5432 user@bastion.example.com

2. Dynamic SOCKS5 Proxy (-D)

Turn your remote server into an instant encrypted browser proxy:

bash
# Start SOCKS5 proxy on local port 1080
ssh -D 1080 -N user@remoteserver.com

Bastion Hosts: SSH ProxyJump

Modern cloud VPCs keep production databases and worker nodes in private subnets with no public IPv4 addresses. Instead of manually SSHing into a bastion and hopping from there, use native ProxyJump (-J):

text
# ~/.ssh/config configuration for transparent bastion hopping
Host bastion
    HostName bastion.production.internal
    User ec2-user
    IdentityFile ~/.ssh/bastion_key.pem

Host internal-worker-01
    HostName 10.0.2.144
    User ubuntu
    ProxyJump bastion
    IdentityFile ~/.ssh/prod_nodes.pem

Now typing ssh internal-worker-01 automatically routes and authenticates through the bastion smoothly in a single step!


SSH Permissions & Common Gotchas

SSH enforces strict filesystem permissions to prevent rogue users on multi-tenant machines from reading private keys:

bash
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub
chmod 600 ~/.ssh/authorized_keys

Interactive Tool: Need to verify octal and symbolic Linux file permissions? Use our free Linux Chmod Permissions Calculator to quickly calculate exact permissions and umask values.

Crucial Server Hardening Fundamentals

Don't leave your server front door open to brute-force bots! Edit /etc/ssh/sshd_config to harden your configuration:

  1. Disable Password Auth: Set PasswordAuthentication no.
  2. Disable Root Login: Set PermitRootLogin no.
  3. Enforce Modern Ciphers: Restrict key exchange to curve25519-sha256.
  4. Firewall Access: Limit SSH port exposure with ufw allow from <your_ip> to any port 22.
  5. Install Fail2Ban: Automatically ban IP addresses exceeding 3 consecutive failed handshakes.

Test Your Knowledge

Interactive Quiz
Question 1 of 2

You need to transfer a large directory containing many files to a remote server. Some files might already exist on the server, and you want to minimize network traffic by only transferring changes. Which tool is most appropriate for this task?

Frequently Asked Questions

Ed25519 uses twisted Edwards curve cryptography. It generates 68-character compact keys that execute signature handshakes substantially faster than 4096-bit RSA keys, while offering superior resistance to side-channel timing attacks.
This occurs when the server's public key fingerprint changes (common after server re-installations). Verify the remote IP address, then remove the stale host entry using ssh-keygen -R hostname_or_ip.
SCP transfers files in their entirety using standard SSH pipes. rsync calculates rolling checksums across both endpoints to transfer only changed blocks, and supports resuming interrupted transfers and syncing file permissions.

Key Takeaways & Best Practices

SSH and SCP are the foundational plumbing of cloud systems and DevOps infrastructure. By adopting Ed25519 keys, structuring your ~/.ssh/config profiles, mastering ProxyJump and port forwarding, and hardening sshd_config, you turn fragile remote access into an encrypted, bulletproof workflow.

You Might Also Like

  • High-Throughput Linux I/O in Rust: io_uring, Tokio & Zero-Copy Networking
  • Building High-Throughput Microservices with Rust and Axum: Complete Production Guide
  • Rust Web Development: Axum vs Actix-web Production Guide (2026)
  • Understanding Rust Lifetimes
Advertisement
Share this article:

Stay Updated

Get the latest posts delivered straight to your inbox.

Free Developer Utilities

Free In-Browser Developer Tools

Clean AI CLI logs, build cron expressions, decode JWTs, and calculate chmod permissions offline.

Explore Tools

Related Articles

eBPF & Cilium in Kubernetes: High-Throughput Routing, Network Policies & Hubble Observability
kubernetesOctober 2, 2026

eBPF & Cilium in Kubernetes: High-Throughput Routing, Network Policies & Hubble Observability

eBPF networking in Kubernetes with Cilium: bypassing iptables/kube-proxy, direct server return (DSR), and Hubble service-mesh flow inspection.

Read more
Istio Ambient Mesh vs Sidecar Architecture: Memory Overhead, Ztunnel & Zero-Trust Security
kubernetesOctober 3, 2026

Istio Ambient Mesh vs Sidecar Architecture: Memory Overhead, Ztunnel & Zero-Trust Security

Evaluating Istio Ambient Mesh ztunnel vs Envoy sidecars: node-level L4 security, L7 waypoint proxies, and memory footprints in multi-tenant clusters.

Read more
Kubernetes Gateway API in Production: Migrating from Ingress-Nginx with Envoy
kubernetesOctober 2, 2026

Kubernetes Gateway API in Production: Migrating from Ingress-Nginx with Envoy

Migrating from ingress-nginx to Kubernetes Gateway API with Envoy: role-oriented routing, cross-namespace HTTPRoutes, and zero-downtime cutover.

Read more
On this page
0%
  • Port 22 and Connectivity
  • Level Up Your SSH Workflow
  • SCP vs. The Alternatives
  • SSH Tunneling & Port Forwarding
  • 1. Local Port Forwarding (-L)
  • 2. Dynamic SOCKS5 Proxy (-D)
  • Bastion Hosts: SSH ProxyJump
  • SSH Permissions & Common Gotchas
  • Test Your Knowledge
  • Frequently Asked Questions
  • Key Takeaways & Best Practices
PreviousPlaywright E2E Testing: 4 Rules for Zero Flaky TestsRead NextIaaS, PaaS, SaaS: A Mental Model That Actually Sticks