首页 文章

使用scp命令时出错“bash:scp:command not found”[关闭]

提问于
浏览
48

我想使用scp命令将本地文件复制到远程服务器,但是在远程服务器中输入用户密码后收到错误消息 .

~]$ scp gitadmin.pub git@123.150.207.18:
git@123.150.207.18's password: 
bash: scp: command not found
lost connection

我使用git用户检查了服务器,似乎可以找到scp命令并且也安装了openssh-clinets .

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.

我对这种情况很困惑 . 我在服务器上缺少一些配置吗? (我们使用RHEL6作为服务器 . )


路径设置是我的错 . 我在/etc/profile.d中添加了“custom.sh”,并在其中添加了以下行,以将/ usr / local / node / bin目录添加到PATH .

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

但格式错误 . 我删除了这对“”,它现在可以正常工作了 . 它应该是:

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

探测错误...... ^ _ ^

3 回答

  • 3

    确保scp命令在客户端和服务器上都可用 on both sides .

    如果这是 FedoraRed Hat Enterprise Linux 和克隆(CentOS),请确保已安装此软件包:

    yum -y install openssh-clients
    

    如果您使用 DebianUbuntu 和克隆,请安装此软件包:

    apt-get install openssh-client
    

    同样,您需要在服务器和客户端上执行此操作,否则您可能会在客户端上遇到"weird"错误消息: scp: command not found 或类似,尽管您在本地使用它 . 这已经困惑了成千上万的人,我猜:)

  • 3

    问题是远程服务器,您是否可以登录到远程服务器并检查“scp”是否有效

    可能的原因: - scp不在路径中 - openssh客户端未正确安装

    了解更多详情http://www.linuxquestions.org/questions/linux-newbie-8/bash-scp-command-not-found-920513/

  • 91

    where 检查是否已安装 scp ,并希望使用 which scp 复制检查

    如果它已经安装,它将打印一条像 /usr/bin/scp Else的路径,使用以下命令安装scp:

    yum -y install openssh-clients
    

    然后复制命令

    scp -r root@192.168.1.1:/var/www/html/database_backup/restore_fullbackup/backup_20140308-023002.sql  /var/www/html/db_bkp/
    

相关问题