{
  "id": 12491523,
  "title": "Using SCP on a Custom Port (and Avoiding the -p vs -P Mix-Up)",
  "url": "https://urgent.news/2026/10/06/using-scp-on-a-custom-port-and-avoiding-the-p-vs-p-mix-up",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-06T23:00:31.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/__3381495fd2b/using-scp-on-a-custom-port-and-avoiding-the-p-vs-p-mix-up-58hn"
  },
  "original_language": "en",
  "account": "When using SCP (Secure Copy) on a custom port, it's important to use the correct capitalization for the port flag. The uppercase -P flag specifies the port for SCP, while lowercase -p is used for preserving file permissions and timestamps. SCP relies on the SSH port, which defaults to TCP port 22. If a server's SSH service listens on a different port, SCP must connect to that same port. For example, if the SSH service listens on port 2222, you would use the command \"scp -P 2222 report.txt deploy@example.com:/var/tmp/\" to upload or download files.\n\nCapitalization is crucial when switching between SSH and SCP commands. SSH uses the lowercase -p flag for the port, while SCP uses the uppercase -P flag. To avoid confusion, it's recommended to double-check the capitalization before troubleshooting the server. For hosts you frequently use, you can add their connection details to the SSH config file (~/.ssh/config). This allows you to use an alias for either SCP or SSH commands, and the configured port is applied without repeating the -P flag.",
  "summary": "If SSH listens on a nonstandard port, SCP needs to connect to that same port. The easy-to-miss detail is capitalization: use uppercase -P with scp , not lowercase -p . SCP uses the SSH port SCP doesn't have a separate network port. It connects through SSH, which uses TCP port 22 by default. If a server's SSH service listens on port 2222 , SCP must connect to 2222 too. For a one-time upload,…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}