[scp] Error when using scp command "bash: scp: command not found"

I want to use scp command to copy a local file to remote server, but I get an error message after input the password of user in remote server.

~]$ scp gitadmin.pub [email protected]:
[email protected]'s password: 
bash: scp: command not found
lost connection

I checked on server using the git user and it seems the scp command can be found and openssh-clinets were installed too.

git@... ~]$ scp
usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 ... [[user@]host2:]file2
git@... ~]$ su root
......
root@... ~]# yum info openssh-clients
Loaded plugins: product-id, subscription-manager
Updating Red Hat repositories.
Installed Packages
Name        : openssh-clients
Arch        : x86_64
Version     : 5.3p1
Release     : 52.el6
Size        : 1.0 M
Repo        : installed
From repo   : anaconda-RedHatEnterpriseLinux-201105101844.x86_64
Summary     : An open source SSH client applications
URL         : http://www.openssh.com/portable.html
License     : BSD
Description : OpenSSH is a free version of SSH (Secure SHell), a program for
            : logging into and executing commands on a remote machine. This
            : package includes the clients necessary to make encrypted
            : connections to SSH servers.

I'm confused for the situation. Did I missing some configuration on server? (We are using RHEL6 as server.)


It's my fault in path setting. I added 'custom.sh' in /etc/profile.d and added following lines in it to add /usr/local/node/bin directory to PATH.

export PATH="/usr/local/node/bin:$PATH" 

But the format is wrong. I removed the pair of '"' and it works OK now. It should be:

export PATH=$PATH:/usr/local/node/bin

A probe mistake...^_^

This question is related to scp openssh rhel

The answer is


Make sure the scp command is available on both sides - both on the client and on the server.

If this is Fedora or Red Hat Enterprise Linux and clones (CentOS), make sure this package is installed:

    yum -y install openssh-clients

If you work with Debian or Ubuntu and clones, install this package:

    apt-get install openssh-client

Again, you need to do this both on the server and the client, otherwise you can encounter "weird" error messages on your client: scp: command not found or similar although you have it locally. This already confused thousands of people, I guess :)


Issue is with remote server, can you login to the remote server and check if "scp" works

probable causes: - scp is not in path - openssh client not installed correctly

for more details http://www.linuxquestions.org/questions/linux-newbie-8/bash-scp-command-not-found-920513/


Check if scp is installed or not on from where you want want to copy check using which scp

If it's already installed, it will print you a path like /usr/bin/scp Else, install scp using:

yum -y install openssh-clients

Then copy command

scp -r [email protected]:/var/www/html/database_backup/restore_fullbackup/backup_20140308-023002.sql  /var/www/html/db_bkp/

Examples related to scp

Copying files from server to local computer using SSH How to copy a file from remote server to local machine? scp files from local to remote machine error: no such file or directory How to download a file from my server using SSH (using PuTTY on Windows) Using putty to scp from windows to Linux SCP Permission denied (publickey). on EC2 only when using -r flag on directories scp copy directory to another server with private key auth Run local python script on remote server Send password when using scp to copy files from one server to another How does `scp` differ from `rsync`?

Examples related to openssh

Starting ssh-agent on Windows 10 fails: "unable to start ssh-agent service, error :1058" Error when using scp command "bash: scp: command not found" Automatically enter SSH password with script How do I verify/check/test/validate my SSH passphrase? Use PPK file in Mac Terminal to connect to remote connection over SSH Best way to use multiple SSH private keys on one client SSH Private Key Permissions using Git GUI or ssh-keygen are too open Convert pem key to ssh-rsa format How do I remove the passphrase for the SSH key without having to create a new key?

Examples related to rhel

Docker CE on RHEL - Requires: container-selinux >= 2.9 How to redirect output of systemd service to a file Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7 RHEL 6 - how to install 'GLIBC_2.14' or 'GLIBC_2.15'? How to run a command as a specific user in an init script? Error when using scp command "bash: scp: command not found" How do you scroll up/down on the console of a Linux VM How to find which version of Oracle is installed on a Linux server (In terminal) Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist Installing Python 3 on RHEL