Documenting the analysis and solving process of SCP problem

Source: Internet
Author: User
Tags define local scp command

introduced         

Linux is a huge and complex system. The OPS or developers who deal with it all day long don't have any problems. Here, I talk about an SCP related to the wonderful problem.


First, the problem description


Two centos6.7 host (host one: 172.16.13.62 and host two: 172.16.13.72), are installed SSH, the relevant SSH connection configuration is not a problem, but in SCP between the two Hosts file transfer replication, the following occurs:

On the host one operation SCP, successfully transfer files from host two to host one. Of course, you can successfully transfer files from host to host two. Such as:

[[Email protected] ~] #scp 172.16.13.72:/root/20160215.log/root[email protected] ' s Password:20160215.log 100% 3434 3.4kb/s 00:00 [[email protected] ~]#

While on the host two operation SCP, do from the host a transfer file to host two o'clock, successfully entered the password, the following conditions appear:

[[Email protected] ~] #scp 172.16.13.62:/root/20160215.log/root[email protected] ' s password:---------change alias Here-----------[[email protected] ~]#

A "change alias here" was printed, and then ended, the SCP did not transfer the file successfully. Of course, from the host two transfer files to host one, is still printing a "change alias here", transmission is not successful.

Why did the SCP succeed on host one, and the operation on host two was unsuccessful? Where does the word "change alias" come from? I made the following analysis:

II. Analysis and resolution

   

In the following analysis, host Two is also called the wrong host, the host one becomes the correct host.

Steps:

1) View debug details of the error host via Scp-v

[[Email protected] ~] #scp-V 172.16.13.62:/root/20160215.log/root

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7C/7A/wKiom1bRLDuyBhNSAABNATRxhbE108.png "title=" {7B ' pa1b{p{wma2[(_d7i}p.png "alt=" Wkiom1brlduybhnsaabnatrxhbe108.png "width=" 748 "height=" 292 "border=" 0 "hspace=" 0 " Vspace= "0" style= "width:748px;height:292px;"/>

It can be seen from debug that the result status of this SCP operation is wrong, but it is not easy to find out where the error is, so I debug on the correct host to compare and analyze.


2) Compare correct host parsing errors

[[Email protected] ~] #scp-V 172.16.13.72:/root/20160215.log/root

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7C/7A/wKiom1bRLuziMmrMAABQDl_YZEU270.png "title=" Success-v.png "width=" 748 "height=" 201 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:748px;height:201px; "alt=" Wkiom1brluzimmrmaabqdl_yzeu270.png "/>

It can be seen from debug that the result status of this SCP operation is correct. After comparison, the error points can be located in the "Send file modes and sink" two portals.


3) analyze where "change alias is Here" appears

As the "change alias here" is discovered when you sign in as a non-interactive login, you can quickly find out where the change alias is located. namely:~/.BASHRC

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7C/79/wKioL1bRMzCAEVqiAAAi9g0JA2U027.png "title=". Bashrc.png "alt=" Wkiol1brmzcaevqiaaai9g0ja2u027.png "width=" 684 "height=" 216 "border=" 0 "hspace=" 0 "vspace=" 0 "style= "WIDTH:684PX;HEIGHT:216PX;"/>

It turns out that it was in front of you. To identify a command alias that you can define in ~/.BASHRC, add an echo echoing print. The relevant echo can be deleted after the SCP can be found to operate normally, problem solving.


4) go back and analyze the error one step deeper cause

One more echo will appear SCP error? Through the access to various relevant information, the operation mode of the SCP command based on SSH mainly has source mode and sink mode Two, after establishing the connection.

If the requester receives the first character that is not the uppercase letter "C", as in the example above, "---------change alias here-----------". The SCP is exited due to the remote shell's configuration file output "join" protocol session.

If the requester receives the first character "C", such as "C0644 3334 20160215.log", you will find an interesting situation where the SCP program will successfully read 3,334 bytes and the remaining bytes of the 20160215.log file will be displayed on the screen.

[Email protected] ~]# SCP 172.16.13.62:20160215.log. [email protected] ' s password:20160215.log 100% 3334 3.3kb/s 00:00 6/index.php "" mozilla/5.0 (Window s NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/47.0.2526.80 safari/537.36 "[[email protected] ~]#

The 20160215.log file that is read will contain "C0644 3334 20160215.log" echo print.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7C/7B/wKiom1bRSNmwaWUBAABRaOkJWSg790.png "title=" _6a{% xo{$%f) ptdce7{fq]r.png "width=" 736 "height=" 98 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:736PX;HEIGHT:98PX; "alt = "Wkiom1brsnmwawubaabraokjwsg790.png"/>

Isn't it funny?

As the problem has been solved, and I have no great determination to carefully study the work of this SCP, so my analysis is over. Friends who want to learn more about the principles of SCP can refer to how the SCP protocol works , which is well written.


Third, add: Bash profile type

Can be divided into two main categories:

Profile class: Provides configuration for the interactive logon shell process

BASHRC class: Provides configuration for non-interactive logon shell processes


global: Effective for all users
style= padding:4px" 8PX; border-collapse:collapse; "width=" 233 ">
user personal: Valid for the current user only
utility
profile class

/etc/profile or  /etc/profile.d/*.sh

~/.bash_profile

1, defining environment variables;

2, run command or script

BASHRC class
/ETC/BASHRC
  ~/.BASHRC

1, define local variables,

2, define command aliases;

Login Type:

Interactive logon Shell process:

Login to open shell process after entering account and password directly through a terminal;

Use the su command: su-username, or login switching performed with su-l USERNAME;

Non-interactive logon shell process:

the login switch performed by SU username;

A terminal opened under a graphical interface;

Run the script


Configuration file Read Order:

Interactive logon Shell process:

/etc/profile--/etc/profile.d/*--and ~/.bash_profile--~/.BASHRC--/ETC/BASHRC


Non-interactive logon shell process:

~/.BASHRC--/ETC/BASHRC-/etc/profile.d/*


Conclusion     

It is most important to find out the problem when solving the problem.

If you have a friend of your own Linux-related wonderful problems, do not leave a person oh, look forward to working with you to discuss sharing.


Attached: If you have questions about the above description, look forward to discussing with your friends. I qq:1084569767

This article is from the "home of small Mosquitoes" blog, be sure to keep this source http://timber.blog.51cto.com/7677013/1745550

Documenting the analysis and solving process of SCP problem

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.