You do not need to enter a password when using sync, ssh, and reverse CT for backup.

Source: Internet
Author: User
Tags ssh port

Rsync backup is very convenient. You only need to install it and do not need to configure anything. However, it takes a long time to get lazy. How can I use rsync without entering a password?

There are many methods on the Internet, and SSH-keygen is the most convenient. However, it seems inconvenient for me to use it. It seems that there is only one password configuration file. Look for other methods.

Keep CT, which needs to be installed. It is very convenient to install it on centos5.4.

Yum install expect

After installation, you can use which history CT to check if it is in/usr/bin/history CT. This is an interactive script. Automatic Interaction is supported. Okay!

In a simple example, synchronize the files under/tmp/123 with/tmp/123 on the 111.222.3.1 server (the remote server is synchronized locally)

#! /Bin/bash
CT-c"
Set timeout 1200;
Spawn/SCP. Sh # the program to be run, or the script
CT {
"* Yes/No *" {send "yesr"; exp_continue}
"* Password *" {send "111 @ 111r";} #111 @ 111 represents the password of the server 111.22.3.1
}
Ct eof ;"

Let's look at/SCP. Sh.

/Usr/bin/rsync-avzp-delete-e 'ssh-P 100'/tmp/12222/rsync-sl@111.22.3.1:/tmp/123

The SSH port is 12222. If not, change the SSH connection port to 10000 or above and change it to correct here.

Rsync-Sl this is the rsync authorized user. During addition, you can directly use useradd-G rsync-Sl to add it to the rsync group.

Check the permission of the/tmp/123 directory in 111.22.3.1. The permission must be rsync: rsync-Sl.

Note:

"* Password *" {send "111 @ 111r";} #111 @ 111 represents the password of the server 111.22.3.1

The password here, if there are some characters such as $, may be problematic, you need to escape. If your password is 123 $ ABC, you must enter

123u0024abc

Point escape:. ==> u002e
Escape of dollar signs: $ ==> u0024
Escape of the multiplication Symbol: ^ ==> u005e
Escape from the left braces: {==> u007b
Escape from left square brackets: [==> u005b
Escape of left parentheses :( ==> u0028
Escape of vertical bars: |=> u007c
Escape of right parentheses: ==> u0029
Asterisk escape: * ==> u002a
Escape of the plus sign: + ==> u002b
Escape question mark :? ==> U003f
Escape the backslash: ==> u005c

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.