我想使用 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
探测错误...^_^
最佳答案
确保 scp 命令在双方上可用 - 在客户端和服务器上。
如果这是 Fedora 或 Red Hat Enterprise Linux 及其克隆 (CentOS),请确保安装此软件包:
yum -y install openssh-clients
如果您使用 Debian 或 Ubuntu 及其克隆版本,请安装此软件包:
apt-get install openssh-client
同样,您需要在服务器和客户端上执行此操作,否则您可能会在客户端上遇到“奇怪”的错误消息:scp:找不到命令
或类似的信息,尽管您在本地有它。我想这已经让成千上万的人感到困惑了:)
关于scp - 使用 scp 命令时出错 "bash: scp: command not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17131048/