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.