[Bug 4007] New: sftp cp -- Directory Destination Issue
bugzilla-daemon at mindrot.org
bugzilla-daemon at mindrot.org
Wed Sep 23 00:23:28 AEST 2026
https://bugzilla.mindrot.org/show_bug.cgi?id=4007
Bug ID: 4007
Summary: sftp cp -- Directory Destination Issue
Product: Portable OpenSSH
Version: 10.5p1
Hardware: 68k
OS: All
Status: NEW
Severity: enhancement
Priority: P5
Component: sftp
Assignee: unassigned-bugs at mindrot.org
Reporter: tamileceguru at gmail.com
Created attachment 3990
--> https://bugzilla.mindrot.org/attachment.cgi?id=3990&action=edit
patch Appends filename to directory similar to get/put command
The sftp interactive client cp command (alias copy) fails when the
destination argument is a bare directory path. The server-side open of
the destination directory itself for writing fails because no filename
is appended. Specifying the full destination path including the
filename works around the bug.
Affected command forms:
cp src.txt /remote/dir -- FAILS
cp src.txt /remote/dir/src.txt -- OK
------------------with directory (FAILED) ----------
sftp> cp /tmp/src/abc.txt /tmp/des
debug2: Sending SSH2_FXP_STAT "/tmp/src/abc.txt"
debug3: Sent message fd 3 T:17 I:7
debug3: Received stat reply T:105 I:7 F:0x000f M:100644
debug3: Sent message SSH2_FXP_OPEN I:8 P:/tmp/src/abc.txt
debug3: Sent message SSH2_FXP_OPEN I:9 P:/tmp/des
remote open("/tmp/des"): Failure
------------------ with Filename (OK) -----------
sftp> cp /tmp/src/abc.txt /tmp/des/scf.txt
debug2: Sending SSH2_FXP_STAT "/tmp/src/abc.txt"
debug3: Sent message fd 3 T:17 I:14
debug3: Received stat reply T:105 I:14 F:0x000f M:100644
debug3: Sent message SSH2_FXP_OPEN I:15 P:/tmp/src/abc.txt
debug3: Sent message SSH2_FXP_OPEN I:16 P:/tmp/des/scf.txt
debug3: Sent message copy-data "/tmp/src/abc.txt" 0 0 ->
"/tmp/des/scf.txt" 0
debug3: SSH2_FXP_STATUS 0
debug3: Sent message SSH2_FXP_CLOSE I:18
debug3: SSH2_FXP_STATUS 0
debug3: Sent message SSH2_FXP_CLOSE I:19
debug3: SSH2_FXP_STATUS 0
sftp> ls /tmp/des/scf.txt
debug3: Sent message fd 3 T:7 I:20
debug3: Received stat reply T:105 I:20 F:0x000f M:100644
debug2: Sending SSH2_FXP_EXTENDED(users-groups-by-id at openssh.com)
debug3: lookup_and_record: record uid 0 => "root"
debug3: lookup_and_record: record gid 0 => "root"
/tmp/des/scf.txt
--------------After Patch-----------
sftp> cp /tmp/src/abc.txt /tmp/des
debug2: Sending SSH2_FXP_STAT "/tmp/des"
debug3: Sent message fd 3 T:17 I:3
debug3: Received stat reply T:105 I:3 F:0x000f M:40755
debug2: Sending SSH2_FXP_STAT "/tmp/src/abc.txt"
debug3: Sent message fd 3 T:17 I:4
debug3: Received stat reply T:105 I:4 F:0x000f M:100644
debug3: Sent message SSH2_FXP_OPEN I:5 P:/tmp/src/abc.txt
debug3: Sent message SSH2_FXP_OPEN I:6 P:/tmp/des/abc.txt
debug3: Sent message copy-data "/tmp/src/abc.txt" 0 0 ->
"/tmp/des/abc.txt" 0
debug3: SSH2_FXP_STATUS 0
debug3: Sent message SSH2_FXP_CLOSE I:8
debug3: SSH2_FXP_STATUS 0
debug3: Sent message SSH2_FXP_CLOSE I:9
debug3: SSH2_FXP_STATUS 0
--
You are receiving this mail because:
You are watching the assignee of the bug.
More information about the openssh-bugs
mailing list