#48057 scp -r follows symlinks

Package:
openssh-client
Source:
openssh
Description:
secure shell (SSH) client, for secure access to remote machines
Submitter:
Hein Roehrig
Date:
2025-07-07 21:51:01 UTC
Severity:
wishlist
Tags:
#48057#5
Date:
1999-10-22 23:55:41 UTC
From:
To:
scp -r follows symlinks, which in case of cycles means that an
infinite amount of data will be copied. I stumbled accross this
problem while trying to copy /etc/apache from one machine to
another; in /etc/apache there is a symlink conf pointing to /etc/
apache.

It would be very useful if this behavior could at least be turned
off.

#48057#10
Date:
2000-12-28 13:32:48 UTC
From:
To:
Does this behaviour still occur with the current ssh-package from
testing? If yes, could you please provide an example for reproducing
this bug?

Ciao
     Christian

#48057#15
Date:
2000-12-30 00:17:01 UTC
From:
To:
Yes, the problem still exists with ssh 1:2.2.0p1-1.1

To reproduce:

cd /tmp
mkdir t1
cd t1
ln -s . t1
cd /tmp
mkdir t2
scp -r -v t1 127.0.0.1:/tmp/t2

Regards,
Hein

#48057#20
Date:
2003-03-26 20:29:54 UTC
From:
To:
Hello,

The behaviour described by Hein Roehrig is still reproducable using
current unstable ssh and the command sequence posted by Hein:

schabi@lunix:/tmp$ ssh -V
OpenSSH_3.5p1 Debian 1:3.5p1-5, SSH protocols 1.5/2.0, OpenSSL
0x0090701f
schabi@lunix:/tmp$ cd /tmp
schabi@lunix:/tmp$ mkdir t1
schabi@lunix:/tmp$ cd t1
schabi@lunix:/tmp/t1$ ln -s . t1
schabi@lunix:/tmp/t1$ cd /tmp
schabi@lunix:/tmp$ mkdir t2
schabi@lunix:/tmp$ scp -r t1 127.0.0.1:/tmp/t2
schabi@127.0.0.1's password:
t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1
/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1/t1: Too many levels
of symbolic links

I just stepped over it when scp'ing my home directory of the university
account to another machine for backup purposes: In the Gnome desktop
directory, there was a symlink backpointing to the home directory, and
so after some copying, my harddist was full (although there were over 2
Gigs free before, and my home only had about 130MB).

I'd wish that scp would recognize symlinks to files that it has already
copied, and then recreate the link on the target.

Alternatively, an option that recreates all symlinks would be useful.

Btw, tar and rsync both handle this case, and even mkisofs has an option
whether to follow symlinks...


Thanks,
Markus

#48057#25
Date:
2007-04-08 09:32:02 UTC
From:
To:
I wrote a patch to fix this problem. I has not been toroughly tested
and it may not apply anymore but it may help some people.

It has been marked as WONTFIX in the OpenSSH Bugzilla.

http://bugzilla.mindrot.org/show_bug.cgi?id=1059
http://openssh.org/faq.html#2.10

Of course nobody is supposed to use scp anymore :)