1

I want to scp a .sh script to /dev/shm but it gives me

error: unexpected filename: .

I don't even see where there would be a lone . in either the script or the directory.

The full command was:

scp -r /opt/PEAS/linPEAS/linpeas.sh jan@10.10.87.42: /dev/shm

(it's from a newbie hacking CTF-type game). I tried adding $(pwd) as suggested in other threads but to no avail.

2 Answers2

2

scp like cp supports copying from multiple sources to a single target directory. In your command

scp -r /opt/PEAS/linPEAS/linpeas.sh jan@10.10.87.42: /dev/shm

/opt/PEAS/linPEAS/linpeas.sh and jan@10.10.87.42: are sources, /dev/shm is a (local) target. For local copying scp falls back to cp. Your command is roughly equivalent to:

cp -r /opt/PEAS/linPEAS/linpeas.sh /dev/shm
scp -r jan@10.10.87.42: /dev/shm

and jan@10.10.87.42: in the latter is equivalent to jan@10.10.87.42:. and means ". (the current working directory) after ssh-ing to jan@10.10.87.42".

While totally local cp -r . /dev/shm (or even scp -r . /dev/shm) may work, scp refuses to download a remote file named .. (I mean the legacy scp which uses SCP, not SFTP. See "preliminary note" in this answer of mine. It appears your scp uses SCP. My tests indicate scp using SFTP can download . from a server.)


With that being said, I suspect maybe you don't want local /dev/shm as the target directory. Maybe you want:

scp -r /opt/PEAS/linPEAS/linpeas.sh jan@10.10.87.42:/dev/shm

where jan@10.10.87.42:/dev/shm is a remote target, it means /dev/shm on 10.10.87.42. The above command will upload local linpeas.sh to remote /dev/shm. You don't really need -r, unless linpeas.sh is a directory.

0

/dev/shm is the shared-memory of Linux, that can be addressed as a disk. It is not an SSH server.

You should be using:

scp -r /opt/PEAS/linPEAS/linpeas.sh /dev/shm

But I'm not sure that this is what you wish to do. The size is limited, and the data would be lost after a reboot.

See for example What Is /dev/shm And Its Practical Usage.

harrymc
  • 498,455