| 1 |
.\" |
| 2 |
.\" scp.1 |
| 3 |
.\" |
| 4 |
.\" Author: Tatu Ylonen <[email protected]> |
| 5 |
.\" |
| 6 |
.\" Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland |
| 7 |
.\" All rights reserved |
| 8 |
.\" |
| 9 |
.\" Created: Sun May 7 00:14:37 1995 ylo |
| 10 |
.\" |
| 11 |
.\" $OpenBSD: scp.1,v 1.115 2025/10/04 21:41:35 naddy Exp $ |
| 12 |
.\" |
| 13 |
.Dd $Mdocdate: October 4 2025 $ |
| 14 |
.Dt SCP 1 |
| 15 |
.Os |
| 16 |
.Sh NAME |
| 17 |
.Nm scp |
| 18 |
.Nd OpenSSH secure file copy |
| 19 |
.Sh SYNOPSIS |
| 20 |
.Nm scp |
| 21 |
.Op Fl 346ABCOpqRrsTv |
| 22 |
.Op Fl c Ar cipher |
| 23 |
.Op Fl D Ar sftp_server_path |
| 24 |
.Op Fl F Ar ssh_config |
| 25 |
.Op Fl i Ar identity_file |
| 26 |
.Op Fl J Ar destination |
| 27 |
.Op Fl l Ar limit |
| 28 |
.Op Fl o Ar ssh_option |
| 29 |
.Op Fl P Ar port |
| 30 |
.Op Fl S Ar program |
| 31 |
.Op Fl X Ar sftp_option |
| 32 |
.Ar source ... target |
| 33 |
.Sh DESCRIPTION |
| 34 |
.Nm |
| 35 |
copies files between hosts on a network. |
| 36 |
.Pp |
| 37 |
.Nm |
| 38 |
uses the SFTP protocol over an |
| 39 |
.Xr ssh 1 |
| 40 |
connection for data transfer, and uses the same authentication and provides |
| 41 |
the same security as a login session. |
| 42 |
.Pp |
| 43 |
.Nm |
| 44 |
will ask for passwords or passphrases if they are needed for |
| 45 |
authentication. |
| 46 |
.Pp |
| 47 |
The |
| 48 |
.Ar source |
| 49 |
and |
| 50 |
.Ar target |
| 51 |
may be specified as a local pathname, a remote host with optional path |
| 52 |
in the form |
| 53 |
.Sm off |
| 54 |
.Oo user @ Oc host : Op path , |
| 55 |
.Sm on |
| 56 |
or a URI in the form |
| 57 |
.Sm off |
| 58 |
.No scp:// Oo user @ Oc host Oo : port Oc Op / path . |
| 59 |
.Sm on |
| 60 |
Local file names can be made explicit using absolute or relative pathnames |
| 61 |
to avoid |
| 62 |
.Nm |
| 63 |
treating file names containing |
| 64 |
.Sq :\& |
| 65 |
as host specifiers. |
| 66 |
.Pp |
| 67 |
When copying between two remote hosts, if the URI format is used, a |
| 68 |
.Ar port |
| 69 |
cannot be specified on the |
| 70 |
.Ar target |
| 71 |
if the |
| 72 |
.Fl R |
| 73 |
option is used. |
| 74 |
.Pp |
| 75 |
The options are as follows: |
| 76 |
.Bl -tag -width Ds |
| 77 |
.It Fl 3 |
| 78 |
Copies between two remote hosts are transferred through the local host. |
| 79 |
This mode is the default, |
| 80 |
but see also the |
| 81 |
.Fl R |
| 82 |
option for copying data directly between two remote hosts. |
| 83 |
Note that when using the legacy SCP protocol (via the |
| 84 |
.Fl O |
| 85 |
flag), this option |
| 86 |
selects batch mode for the second host as |
| 87 |
.Nm |
| 88 |
cannot ask for passwords or passphrases for both hosts. |
| 89 |
.It Fl 4 |
| 90 |
Forces |
| 91 |
.Nm |
| 92 |
to use IPv4 addresses only. |
| 93 |
.It Fl 6 |
| 94 |
Forces |
| 95 |
.Nm |
| 96 |
to use IPv6 addresses only. |
| 97 |
.It Fl A |
| 98 |
Allows forwarding of |
| 99 |
.Xr ssh-agent 1 |
| 100 |
to the remote system. |
| 101 |
The default is not to forward an authentication agent. |
| 102 |
.It Fl B |
| 103 |
Selects batch mode (prevents asking for passwords or passphrases). |
| 104 |
.It Fl C |
| 105 |
Compression enable. |
| 106 |
Passes the |
| 107 |
.Fl C |
| 108 |
flag to |
| 109 |
.Xr ssh 1 |
| 110 |
to enable compression. |
| 111 |
.It Fl c Ar cipher |
| 112 |
Selects the cipher to use for encrypting the data transfer. |
| 113 |
This option is directly passed to |
| 114 |
.Xr ssh 1 . |
| 115 |
.It Fl D Ar sftp_server_path |
| 116 |
Connect directly to a local SFTP server program rather than a |
| 117 |
remote one via |
| 118 |
.Xr ssh 1 . |
| 119 |
This option may be useful in debugging the client and server. |
| 120 |
.It Fl F Ar ssh_config |
| 121 |
Specifies an alternative |
| 122 |
per-user configuration file for |
| 123 |
.Nm ssh . |
| 124 |
This option is directly passed to |
| 125 |
.Xr ssh 1 . |
| 126 |
.It Fl i Ar identity_file |
| 127 |
Selects the file from which the identity (private key) for public key |
| 128 |
authentication is read. |
| 129 |
This option is directly passed to |
| 130 |
.Xr ssh 1 . |
| 131 |
.It Fl J Ar destination |
| 132 |
Connect to the target host by first making an |
| 133 |
.Nm |
| 134 |
connection to the jump host described by |
| 135 |
.Ar destination |
| 136 |
and then establishing a TCP forwarding to the ultimate destination from |
| 137 |
there. |
| 138 |
Multiple jump hops may be specified separated by comma characters. |
| 139 |
This is a shortcut to specify a |
| 140 |
.Cm ProxyJump |
| 141 |
configuration directive. |
| 142 |
This option is directly passed to |
| 143 |
.Xr ssh 1 . |
| 144 |
.It Fl l Ar limit |
| 145 |
Limits the used bandwidth, specified in Kbit/s. |
| 146 |
.It Fl O |
| 147 |
Use the legacy SCP protocol for file transfers instead of the SFTP protocol. |
| 148 |
Forcing the use of the SCP protocol may be necessary for servers that do |
| 149 |
not implement SFTP, for backwards-compatibility for particular filename |
| 150 |
wildcard patterns and for expanding paths with a |
| 151 |
.Sq ~ |
| 152 |
prefix for older SFTP servers. |
| 153 |
.It Fl o Ar ssh_option |
| 154 |
Can be used to pass options to |
| 155 |
.Nm ssh |
| 156 |
in the format used in |
| 157 |
.Xr ssh_config 5 . |
| 158 |
This is useful for specifying options |
| 159 |
for which there is no separate |
| 160 |
.Nm scp |
| 161 |
command-line flag. |
| 162 |
For full details of the options listed below, and their possible values, see |
| 163 |
.Xr ssh_config 5 . |
| 164 |
.Pp |
| 165 |
.Bl -tag -width Ds -offset indent -compact |
| 166 |
.It AddKeysToAgent |
| 167 |
.It AddressFamily |
| 168 |
.It BatchMode |
| 169 |
.It BindAddress |
| 170 |
.It BindInterface |
| 171 |
.It CASignatureAlgorithms |
| 172 |
.It CanonicalDomains |
| 173 |
.It CanonicalizeFallbackLocal |
| 174 |
.It CanonicalizeHostname |
| 175 |
.It CanonicalizeMaxDots |
| 176 |
.It CanonicalizePermittedCNAMEs |
| 177 |
.It CertificateFile |
| 178 |
.It ChannelTimeout |
| 179 |
.It CheckHostIP |
| 180 |
.It Ciphers |
| 181 |
.It ClearAllForwardings |
| 182 |
.It Compression |
| 183 |
.It ConnectTimeout |
| 184 |
.It ConnectionAttempts |
| 185 |
.It ControlMaster |
| 186 |
.It ControlPath |
| 187 |
.It ControlPersist |
| 188 |
.It DynamicForward |
| 189 |
.It EnableEscapeCommandline |
| 190 |
.It EnableSSHKeysign |
| 191 |
.It EscapeChar |
| 192 |
.It ExitOnForwardFailure |
| 193 |
.It FingerprintHash |
| 194 |
.It ForkAfterAuthentication |
| 195 |
.It ForwardAgent |
| 196 |
.It ForwardX11 |
| 197 |
.It ForwardX11Timeout |
| 198 |
.It ForwardX11Trusted |
| 199 |
.It GSSAPIAuthentication |
| 200 |
.It GSSAPIDelegateCredentials |
| 201 |
.It GatewayPorts |
| 202 |
.It GlobalKnownHostsFile |
| 203 |
.It HashKnownHosts |
| 204 |
.It Host |
| 205 |
.It HostKeyAlgorithms |
| 206 |
.It HostKeyAlias |
| 207 |
.It HostbasedAcceptedAlgorithms |
| 208 |
.It HostbasedAuthentication |
| 209 |
.It Hostname |
| 210 |
.It IPQoS |
| 211 |
.It IdentitiesOnly |
| 212 |
.It IdentityAgent |
| 213 |
.It IdentityFile |
| 214 |
.It IgnoreUnknown |
| 215 |
.It Include |
| 216 |
.It KbdInteractiveAuthentication |
| 217 |
.It KbdInteractiveDevices |
| 218 |
.It KexAlgorithms |
| 219 |
.It KnownHostsCommand |
| 220 |
.It LocalCommand |
| 221 |
.It LocalForward |
| 222 |
.It LogLevel |
| 223 |
.It LogVerbose |
| 224 |
.It MACs |
| 225 |
.It NoHostAuthenticationForLocalhost |
| 226 |
.It NumberOfPasswordPrompts |
| 227 |
.It ObscureKeystrokeTiming |
| 228 |
.It PKCS11Provider |
| 229 |
.It PasswordAuthentication |
| 230 |
.It PermitLocalCommand |
| 231 |
.It PermitRemoteOpen |
| 232 |
.It Port |
| 233 |
.It PreferredAuthentications |
| 234 |
.It ProxyCommand |
| 235 |
.It ProxyJump |
| 236 |
.It ProxyUseFdpass |
| 237 |
.It PubkeyAcceptedAlgorithms |
| 238 |
.It PubkeyAuthentication |
| 239 |
.It RekeyLimit |
| 240 |
.It RemoteCommand |
| 241 |
.It RemoteForward |
| 242 |
.It RequestTTY |
| 243 |
.It RequiredRSASize |
| 244 |
.It RevokedHostKeys |
| 245 |
.It SecurityKeyProvider |
| 246 |
.It SendEnv |
| 247 |
.It ServerAliveCountMax |
| 248 |
.It ServerAliveInterval |
| 249 |
.It SessionType |
| 250 |
.It SetEnv |
| 251 |
.It StdinNull |
| 252 |
.It StreamLocalBindMask |
| 253 |
.It StreamLocalBindUnlink |
| 254 |
.It StrictHostKeyChecking |
| 255 |
.It SyslogFacility |
| 256 |
.It TCPKeepAlive |
| 257 |
.It Tag |
| 258 |
.It Tunnel |
| 259 |
.It TunnelDevice |
| 260 |
.It UpdateHostKeys |
| 261 |
.It User |
| 262 |
.It UserKnownHostsFile |
| 263 |
.It VerifyHostKeyDNS |
| 264 |
.It VisualHostKey |
| 265 |
.It XAuthLocation |
| 266 |
.El |
| 267 |
.It Fl P Ar port |
| 268 |
Specifies the port to connect to on the remote host. |
| 269 |
Note that this option is written with a capital |
| 270 |
.Sq P , |
| 271 |
because |
| 272 |
.Fl p |
| 273 |
is already reserved for preserving the times and mode bits of the file. |
| 274 |
.It Fl p |
| 275 |
Preserves modification times, access times, and file mode bits from the |
| 276 |
source file. |
| 277 |
.It Fl q |
| 278 |
Quiet mode: disables the progress meter as well as warning and diagnostic |
| 279 |
messages from |
| 280 |
.Xr ssh 1 . |
| 281 |
.It Fl R |
| 282 |
Copies between two remote hosts are transferred through the local host |
| 283 |
by default. |
| 284 |
This option instead copies between two remote hosts by connecting to the origin |
| 285 |
host and executing |
| 286 |
.Nm |
| 287 |
there. |
| 288 |
This requires that |
| 289 |
.Nm |
| 290 |
running on the origin host can authenticate to the destination host without |
| 291 |
requiring a password. |
| 292 |
.It Fl r |
| 293 |
Recursively copy entire directories. |
| 294 |
Note that |
| 295 |
.Nm |
| 296 |
follows symbolic links encountered in the tree traversal. |
| 297 |
.It Fl S Ar program |
| 298 |
Name of |
| 299 |
.Ar program |
| 300 |
to use for the encrypted connection. |
| 301 |
The program must understand |
| 302 |
.Xr ssh 1 |
| 303 |
options. |
| 304 |
.It Fl T |
| 305 |
Disable strict filename checking. |
| 306 |
By default when copying files from a remote host to a local directory |
| 307 |
.Nm |
| 308 |
checks that the received filenames match those requested on the command-line |
| 309 |
to prevent the remote end from sending unexpected or unwanted files. |
| 310 |
Because of differences in how various operating systems and shells interpret |
| 311 |
filename wildcards, these checks may cause wanted files to be rejected. |
| 312 |
This option disables these checks at the expense of fully trusting that |
| 313 |
the server will not send unexpected filenames. |
| 314 |
.It Fl v |
| 315 |
Verbose mode. |
| 316 |
Causes |
| 317 |
.Nm |
| 318 |
and |
| 319 |
.Xr ssh 1 |
| 320 |
to print debugging messages about their progress. |
| 321 |
This is helpful in |
| 322 |
debugging connection, authentication, and configuration problems. |
| 323 |
.It Fl X Ar sftp_option |
| 324 |
Specify an option that controls aspects of SFTP protocol behaviour. |
| 325 |
The valid options are: |
| 326 |
.Bl -tag -width Ds |
| 327 |
.It Cm nrequests Ns = Ns Ar value |
| 328 |
Controls how many concurrent SFTP read or write requests may be in progress |
| 329 |
at any point in time during a download or upload. |
| 330 |
By default 64 requests may be active concurrently. |
| 331 |
.It Cm buffer Ns = Ns Ar value |
| 332 |
Controls the maximum buffer size for a single SFTP read/write operation used |
| 333 |
during download or upload. |
| 334 |
By default a 32KB buffer is used. |
| 335 |
.El |
| 336 |
.El |
| 337 |
.Sh EXIT STATUS |
| 338 |
.Ex -std scp |
| 339 |
.Sh SEE ALSO |
| 340 |
.Xr sftp 1 , |
| 341 |
.Xr ssh 1 , |
| 342 |
.Xr ssh-add 1 , |
| 343 |
.Xr ssh-agent 1 , |
| 344 |
.Xr ssh-keygen 1 , |
| 345 |
.Xr ssh_config 5 , |
| 346 |
.Xr sftp-server 8 , |
| 347 |
.Xr sshd 8 |
| 348 |
.Sh HISTORY |
| 349 |
.Nm |
| 350 |
is based on the rcp program in |
| 351 |
.Bx |
| 352 |
source code from the Regents of the University of California. |
| 353 |
.Pp |
| 354 |
Since OpenSSH 9.0, |
| 355 |
.Nm |
| 356 |
has used the SFTP protocol for transfers by default. |
| 357 |
.Sh AUTHORS |
| 358 |
.An Timo Rinne Aq Mt [email protected] |
| 359 |
.An Tatu Ylonen Aq Mt [email protected] |
| 360 |
.Sh CAVEATS |
| 361 |
The legacy SCP protocol (selected by the |
| 362 |
.Fl O |
| 363 |
flag) requires execution of the remote user's shell to perform |
| 364 |
.Xr glob 3 |
| 365 |
pattern matching. |
| 366 |
This requires careful quoting of any characters that have special meaning to |
| 367 |
the remote shell, such as quote characters. |