Linuxbash: scp: commandnotfound problem record
1. scp Error
[Root @ localhost soft] # scpjdk-7u55-linux-x64.tar.gz 192.168.121.246:/soft/
Root@192.168.121.246's password:
Bash: scp: command not found
Lost connection
[Root @ localhost soft] #
2. debug-v
[Root @ localhost soft] # scp -vjdk-7u55-linux-x64.tar.gz 192.168.121.246:/soft/
Executing: program/usr/bin/ssh host192.168.121.246, user (unspecified), command scp-v-t/soft/
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb2013
Debug1: Reading configuration data/etc/ssh/ssh_config
Debug1: Applying options *
Debug1: Connecting to 192.168.121.246 [192.168.121.246] port 22.
Debug1: Connection established.
Debug1: permanently_set_uid: 0/0
Debug1: identity file/root/. ssh/identitytype-1
Debug1: identity file/root/. ssh/identity-cert type-1
Debug1: identity file/root/. ssh/id_rsatype-1
Debug1: identity file/root/. ssh/id_rsa-cert-type-1
Debug1: identity file/root/. ssh/id_dsatype-1
Debug1: identity file/root/. ssh/id_dsa-cert-type-1
Debug1: identity file/root/. ssh/id_ecdsatype-1
Debug1: identity file/root/. ssh/id_ecdsa-cert-type-1
Debug1: Remote protocol version 2.0, remotesoftware version OpenSSH_5.3
Debug1: match: OpenSSH_5.3 pat OpenSSH *
Debug1: Enabling compatibility mode forprotocol 2.0
Debug1: Local version stringSSH-2.0-OpenSSH_5.3
Debug1: SSH2_MSG_KEXINIT sent
Debug1: SSH2_MSG_KEXINIT initialized ed
Debug1: kex: server-> client aes128-ctrhmac-md5 none
Debug1: kex: client-> server aes128-ctrhmac-md5 none
Debug1: SSH2_MSG_KEX_DH_GEX_REQUEST (1024 <1024) sent
Debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
Debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
Debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
Debug1: Host '192. 168.121.246 'is known andmatches the RSA host key.
Debug1: Found key in/root/. ssh/known_hosts: 1
Debug1: ssh_rsa_verify: signature correct
Debug1: SSH2_MSG_NEWKEYS sent
Debug1: expecting SSH2_MSG_NEWKEYS
Debug1: SSH2_MSG_NEWKEYS received ed
Debug1: SSH2_MSG_SERVICE_REQUEST sent
Debug1: SSH2_MSG_SERVICE_ACCEPT received ed
Debug1: Authentications that can continue: publickey, gssapi-keyex, gssapi-with-mic, password
Debug1: Next authentication method: gssapi-keyex
Debug1: No valid Key exchange context
Debug1: Next authentication method: gssapi-with-mic
Debug1: Unspecified GSS failure. Minor code may provide more information
Cannot determine realm for numeric hostaddress
Debug1: Unspecified GSS failure. Minor code may provide more information
Cannot determine realm for numeric hostaddress
Debug1: Unspecified GSS failure. Minor code may provide more information
Debug1: Unspecified GSS failure. Minor code may provide more information
Cannot determine realm for numeric hostaddress
Debug1: Next authentication method: publickey
Debug1: Trying private key:/root/. ssh/identity
Debug1: Trying private key:/root/. ssh/id_rsa
Debug1: Trying private key:/root/. ssh/id_dsa
Debug1: Trying private key:/root/. ssh/id_ecdsa
Debug1: Next authentication method: password
Root@192.168.121.246's password:
The following information is displayed:
......
Debug1: Host '192. 168.121.246 'is known andmatches the RSA host key.
Debug1: Found key in/root/. ssh/known_hosts: 1
Debug1: ssh_rsa_verify: signature correct
Debug1: SSH2_MSG_NEWKEYS sent
Debug1: expecting SSH2_MSG_NEWKEYS
Debug1: SSH2_MSG_NEWKEYS received ed
Debug1: SSH2_MSG_SERVICE_REQUEST sent
Debug1: SSH2_MSG_SERVICE_ACCEPT received ed
Debug1: Authentications that can continue: publickey, gssapi-keyex, gssapi-with-mic, password
Debug1: Next authentication method: gssapi-keyex
Debug1: No valid Key exchange context
Debug1: Next authentication method: gssapi-with-mic
......
From debug1: No valid Key exchangecontext, we can see that the problem should be the scp problem on the receiving end server.
3. Go to the acceptor 121.246 to view the scp
[Root @ localhost ~] # Type scp
-Bash: type: scp: not found
[Root @ localhost ~] #
Sure enough, scp is not recognized. Try yum installation, as shown below. It is invalid:
[Root @ localhost ~] # Yum install-y scp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* Base: ftp.sjtu.edu.cn
* Extras: mirrors.163.com
* Updates: centos.ustc.edu.cn
Setting up Install Process
No package scp available.
Error: Nothing to do
[Root @ localhost ~] #
Baidu to, yum install scp package, is openssh-clients, so re-install yum
Run yum install openssh-clients *-y to install
OK. check and scp can be used, as shown below:
[Root @ localhost ~] # Type scp
Scp is/usr/bin/scp
[Root @ localhost ~] #
4. Now the scp is successful on the original server.
[Root @ localhost soft] # scpjdk-7u55-linux-x64.tar.gz 192.168.121.246:/soft/
Root@192.168.121.246's password:
Jdk-7u55-linux-x64.tar.gz 100% 132 MB 131.8 MB/s
[Root @ localhost soft] #
5. Summary
Scp is successful. You need to install the scp service on both servers.