alpinelinux / docker-alpine

Official Alpine Linux Docker image. Win at minimalism!
MIT License
1.04k stars 261 forks source link

alpine 3.16+ cannot run scp #293

Open defung opened 1 year ago

defung commented 1 year ago

Hi,

I'm facing an issue where both alpine 3.16 and 3.17 fails to run scp. Here are the steps:

$ docker run -it --rm alpine:3.16 sh

/ # apk add --update openssh
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
(1/10) Installing openssh-keygen (9.0_p1-r2)
(2/10) Installing ncurses-terminfo-base (6.3_p20220521-r0)
(3/10) Installing ncurses-libs (6.3_p20220521-r0)
(4/10) Installing libedit (20210910.3.1-r0)
(5/10) Installing openssh-client-common (9.0_p1-r2)
(6/10) Installing openssh-client-default (9.0_p1-r2)
(7/10) Installing openssh-sftp-server (9.0_p1-r2)
(8/10) Installing openssh-server-common (9.0_p1-r2)
(9/10) Installing openssh-server (9.0_p1-r2)
(10/10) Installing openssh (9.0_p1-r2)
Executing busybox-1.35.0-r17.trigger
OK: 12 MiB in 24 packages

/ # scp user1@nas.local.lan:/home/user1/test.txt .
sh: /opt/libexec/sftp-server: not found
scp: Connection closed

/ # 

alpine:3.15 works fine though:

$ docker run -it --rm alpine:3.15 sh

/ # apk add --update openssh
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
(1/10) Installing openssh-keygen (8.8_p1-r1)
(2/10) Installing ncurses-terminfo-base (6.3_p20211120-r1)
(3/10) Installing ncurses-libs (6.3_p20211120-r1)
(4/10) Installing libedit (20210910.3.1-r0)
(5/10) Installing openssh-client-common (8.8_p1-r1)
(6/10) Installing openssh-client-default (8.8_p1-r1)
(7/10) Installing openssh-sftp-server (8.8_p1-r1)
(8/10) Installing openssh-server-common (8.8_p1-r1)
(9/10) Installing openssh-server (8.8_p1-r1)
(10/10) Installing openssh (8.8_p1-r1)
Executing busybox-1.34.1-r7.trigger
OK: 12 MiB in 24 packages

/ # scp user1@nas.local.lan:/home/user1/test.txt .
test.txt                                                                           100% 2778     1.1MB/s   00:00

/ # 

If this doesn't belong here, please let me know where I should post this.

Elkenfugel commented 1 year ago

@defung I believe this is due to openssh version 9 change of default scp protocol. Please see:

You may try the option scp -O user1@nas.local.lan:/home/user1/test.txt . That should bring the protocol back to what the default was in openssh version 8.*, instead of the current default of sftp.

There might be some security considerations involved with using scp protocol vs sftp protocol there, but I wouldn't be able to expand on that...perhaps someone could?

As for another route, sshd may need further configuration: