'Command not found' error when trying to scp file

'Command not found' error when trying to scp file

I've installed Raspbian on a Raspberry Pi and I'm trying to send a test file from my Macbook to the Pi over my LAN, but I keep getting the error:

bash: scp: command not found

followed by

lost connection

I have successfully gotten into the Pi through my Macbook using SSH and the scp command definitely exists on the Pi. Also tried reinstalling OpenSSH-Server on the Pi.

The syntax of my command is:

scp afile.rtf [email protected]:~

EDIT: If it's relevant at all, when I run whereis scp on the Pi or while SSHing into the Pi on my mac the output is:

scp: /usr/bin/scp /usr/share/man/man1/scp.1.gz

答案1

The error message is trying to tell you that your shell cannot find the scp command.

It seems you're running this command on the Pi, not on the Mac, because if you were running it on the Mac you should not get such error, as scp is normally installed by default, typically in /usr/bin/scp, and /usr/bin should be on PATH. On the other hand, scp might not be installed on the Pi, that's why I suspect you're running the command on the wrong machine. So try again, and make sure you are on the Mac's shell, not on the Pi's shell.

You've mentioned the openssh-server package. That doesn't include the scp tool. Based on your problem description so far, I don't think you need scp on the Pi, but if you want to install it, the name of the package that provides it is openssh-client.

答案2

I eventually figured it out. It was to do with the PATH variable. Everything I've read seems to suggest that you can use .bashrc or the environment file to set your PATH variable, and I opted for .bashrc as that seemed to be the traditional way.

I set it in the environment file and it worked.

相关内容