What if CentOS cannot use the scp command?

Source: Internet
Author: User
Tags gz file centos scp command

What if CentOS cannot use the scp command?

In the test, files must be transferred between two virtual machines. The scp command is first generated, and the result is as follows:

-Bash: scp: command not found

If you use the yum install scp command for installation, the result is:

No package scp available.

Later I found that scp should belong to the openssh-clients package and run:

Yum install openssh-clients

Run scp again. Run again:

Scp 1.so root@192.168.0.182:/root/

After entering the password, the system prompts again:

Bash: scp: command not found

Install openssh-clients on the target host, and try again to solve the problem.
The above describes how CentOS cannot use the scp command. The reason why it cannot be used is that the yum install scp command is used, run yum install openssh-clients and then run scp.

Scp command usage

 

Due to work requirements, you need to copy the files on server A to server B. I am too lazy to build FTP and Samba servers, so I plan to use the scp command, which is replicated through the ssh protocol.

 

You can view the scp command in the help document. As follows:

 

Scp -- help

 

Man scp

 

 

 

By viewing the help documentation, we can easily find that the scp command is very simple. The basic format of the scp command is as follows: scp [OPTIONS] file_source file_target

 

OPTIONS:

 

-V is the same as-v in most linux commands to display the progress. Can be used to view connections, authentication, or configuration errors

 

-C enable compression options

 

-P select Port

 

-R copy Directory

 

We will first test the local copy of files and directories to the remote server.

 

Copy an object as follows:

 

Scp./ilanni.tar.gz root@192.168.1.102:/ks

 


 

 

The command is to copy the ilanni.tar.gz file under the current directory to the/ks Directory of the server 192.168.1.102. Of course, during replication, you need to enter the password of the root user of the 192.168.1.102 server.

 

Log on to the 192.168.1.102 server and check whether the replication was successful. As follows:

 

 

You can see that the ilanni.tar.gz file has been successfully copied to the/ks Directory of the 192.168.1.102 server.

 

The above copy is the file. Now let's test the copy directory. As follows:

 

Scp-r./ilanni root@192.168.1.102:/ks

 

 

Log on to the 192.168.1.102 server and check the copied directory. As follows:

 

 

Through the screenshot and related information above, we can now see that the local computer can be completely copied to the remote server through the scp command.

 

Next we will start the test and copy the files and directories of the remote server to the local device.

 

To test a single file, run the following command:

 

Scp root@192.168.1.102:/ks. cfg ./

 

 

This command means to copy the ks. cfg file under the/ks Directory of the server 192.168.1.102 to the current directory through the scp command. Of course, during replication, you need to enter the password of the root user of the 192.168.1.102 server.

 

We can see from the screenshot that the ks. cfg file has been successfully copied.

 

The following example shows how to copy a directory from a remote server:

 

Scp-r root@192.168.1.102:/ks/ilanni ./

 

 

 

 

As shown in the preceding figure, the scp command has successfully copied all the ilanni directories in the/ks Directory of the server 192.168.1.102 to the current directory.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.