I run Ubuntu 12.04 64-bit as my local Desktop OS. I’ve run the “SCP” command multiple times to multiple machines from my own PC when I’m moving files around, but for some reason when I tried to SCP, I got the following error:
dream@dream-C32A-H9:~/Downloads$ scp myfile.zip email@example.com:/root firstname.lastname@example.org's password: bash: scp: command not found lost connection
Okay… so that doesn’t make any sense. I use SCP all the time. What is *really* going on here? To find out, I ran SCP in verbose mode, whcih you can do by adding the “-v” switch to your SCP command:
:::snip::: debug1: Authentication succeeded (password). Authenticated to myserver.viviotech.net ([255.255.255.255]:22). debug1: channel 0: new [client-session] debug1: Requesting email@example.com debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 debug1: Sending command: scp -v -t -- /root bash: scp: command not found debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: client_input_channel_req: channel 0 rtype firstname.lastname@example.org reply 0 debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK Transferred: sent 2048, received 2104 bytes, in 0.0 seconds Bytes per second: sent 60339.9, received 61989.9 debug1: Exit status 127 lost connection
Ah… see these two lines:
debug1: Sending command: scp -v -t -- /root bash: scp: command not found
So, we see that it was the REMOTE server that’s complaining about the “command not found”. Well, that should be easy enough to fix. I SSH’d over to the remote server and I was going to install SCP on it but I couldn’t remember what package SCP was in, so I looked for it using YUM (since the remote machine was a CentOS machine):
[root@myserver ~]# yum provides */scp Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.mirror.facebook.net * extras: ftp.osuosl.org * updates: mirrors.cat.pdx.edu r1soft/filelists | 14 kB 00:00 updates/filelists_db | 2.9 MB 00:01 openssh-clients-5.3p1-81.el6.x86_64 : An open source SSH client applications Repo : base Matched from: Filename : /usr/bin/scp
There we go. So the SCP command is provided by openssh-clients. I installed that by running the following:
yum -y install openssh-clients
Then I ran my SCP command again, and my file was uploaded without a hitch!
Hope this helps anyone else experiencing the same issues.