p0 scp

1. Authentication & Authorization Failures

Error Message

Cause

Resolution

Please run 'p0 login <organization>' to use the P0 CLI.

You aren’t logged in or your identity file is missing.

Execute p0 login <ORG ID> and complete the OIDC flow.

Could not load credentials for "<name>"

Corrupt or expired credential cache.

Remove the cache directory (rm -rf ~/.p0/cache) and re-run p0 login

Silent hang or immediate exit without output

Token auto-refresh failed but no explicit error.

Clear credentials (p0 logout or delete identity.json) and log in again.


2. Host & Argument Validation

Symptom / Message

Cause

Resolution

Exactly one host (source or destination) must be remote.

Both or neither argument uses <hostname>: syntax.

Prefix exactly one of source or destination with <hostname>:.

Could not determine host identifier from source or destination

Malformed <hostname>:<path> (missing or extra colon).

Ensure exactly one colon with no spaces, e.g., prod-db:/var/backups/file.sql.

Azure SSH does not currently support specifying a port…

You passed -P or -p flags with --provider azure.

Remove port flags; Azure integration only works on default port 22.


3. Network & Connectivity Issues

Error Message

Cause

Resolution

Network error: Unable to reach the server at https://…/command/.

Cannot connect to P0’s API (DNS, proxy, firewall).

- Verify internet access and DNS.- Check appUrl in ~/.p0/config.json.- Whitelist the endpoint.

Underlying scp hangs or times out

SSH port blocked or host unreachable.

- Ensure network access to the remote host on port 22.- Confirm the hostname via P0’s session list.


4. Provisioning & SSH Key Issues

Symptom / Message

Cause

Resolution

No prompt, then SSH authentication failure

P0 failed to obtain or write the temporary private key.

- Run with --debug to see provisioning logs.- Check file permissions in $HOME/.ssh.

Permission denied (publickey)

Remote host doesn’t accept the P0-issued key.

- Confirm the host is managed by P0 SSH integration.- Verify the Linux username mapping.


5. Underlying scp Errors

Error Message

Cause

Resolution

scp: command not found

No scp binary installed.

Install OpenSSH client (openssh-client on Linux).

Permission denied (writing file)

Local filesystem permissions issue.

Check directory permissions; ensure you have write access and sufficient disk space.

No such file or directory

Remote path doesn’t exist.

Verify remote path is correct and parent directories exist.


6. Debugging & Logs

  • Enable P0 debug

p0 scp --debug <source> <destination>
  • Shows API calls, key issuance, and provisioning messages.

  • Prints low-level HTTP request/response details.

  • Inspect raw provisioning

    In debug mode, note the path to the temporary private key and try a manual:

scp -i /path/to/temp_key <source> <destination>
  • to isolate SSH vs. provisioning errors.


7. Tips & Best Practices

  • Use --reason for audit trails, especially when using --sudo.

  • Quote paths with spaces:

p0 scp "prod-web:/var/www/My Site/index.html" ./
  • Combine flags correctly:

    • P0 options before --

    • scp options after --

p0 scp --recursive ./dir prod-app:/opt/app/ -- -C -P 2222
  • Confirm valid SSH destinations before copying:

p0 ls ssh session destination --size 10
  • Ensures your target hostname exists in P0’s session destinations.

  • Automate with debug when iterating:

p0 scp --debug ./file.txt my-host:/tmp/

Last updated