How to Use SCP?

Open a terminal

Copy a local file to a remote server: `scp /path/to/localfile user@remotehost:/path/to/destination/`

Copy a remote file to your local machine: `scp user@remotehost:/path/to/remotefile /path/to/localdestination/`

Copy a directory recursively: `scp -r /path/to/localdir user@remotehost:/path/to/destination/`

Specify a custom port: `scp -P 2222 /path/to/localfile user@remotehost:/path/to/destination/`

Use a private key for authentication: `scp -i /path/to/keyfile /path/to/localfile user@remotehost:/path/to/destination/`

Preserve file times and modes: `scp -p /path/to/localfile user@remotehost:/path/to/destination/`

Enable verbose output: `scp -v /path/to/localfile user@remotehost:/path/to/destination/`

Copy between two remote hosts: `scp user1@host1:/path/to/file user2@host2:/path/to/destination/`

Quote paths with spaces: `scp “My File.txt” user@remotehost:”/path with spaces/”`

Verify the destination path and permissions before copying

Suggested for You

Trending Today