1
2
3
4
5
6
|
[root@yong ~]
# scp /root/iptables.sh [email protected]:/data
The authenticity of host
'192.168.20.10 (192.168.20.10)'
can't be established.
RSA key fingerprint is 84:47:af:bf:11:69:43:aa:
bc
:fe:9b:d6:08:b4:c4:1a.
Are you sure you want to
continue
connecting (
yes
/no
)?
yes
iptables.sh 100% 254 0.3KB
/s
00:00
|
1
2
3
4
5
6
7
8
|
[root@yong
rsync
]
# scp -r /root/rsync/test1/ 192.168.20.10:/data/a/
[email protected]'s password:
1 100% 0 0.0KB
/s
00:00
1.txt 100% 0 0.0KB
/s
00:00
2 100% 0 0.0KB
/s
00:00
2.txt 100% 0 0.0KB
/s
00:00
aa 100% 0 0.0KB
/s
00:00
3 100% 0 0.0KB
/s
00:00
|
1
2
3
4
5
6
7
|
[root@yong ~]
# rsync -av test.txt /tmp/a.txt
sending incremental
file
list
test
.txt
sent 279 bytes received 31 bytes 620.00 bytes
/sec
total size is 203 speedup is 0.65
[root@yong ~]
# ls /tmp/a.txt
/tmp/a
.txt
|
1
2
3
4
5
6
|
[root@yong ~]
# rsync -av test.txt 192.168.20.10:/data/
[email protected]'s password:
sending incremental
file
list
test
.txt
sent 279 bytes received 31 bytes 88.57 bytes
/sec
total size is 203 speedup is 0.65
|
1
2
3
4
5
6
|
[root@yong ~]
# rsync -av 192.168.20.10:/data/httpd ./
[email protected]'s password:
receiving incremental
file
list
httpd
sent 30 bytes received 7538228 bytes 886853.88 bytes
/sec
total size is 7537230 speedup is 1.00
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@yong ~]
# mkdir rsync
[root@yong ~]
# cd rsync/
[root@yong
rsync
]
# mkdir test1
[root@yong
rsync
]
# cd test1
[root@yong test1]
# touch 1 2 3
[root@yong test1]
# ln -s /root/123.txt ./123.txt
[root@yong test1]
# ls -l
-rw-r--r-- 1 root root 0 Apr 22 16:02 1
lrwxrwxrwx 1 root root 13 Apr 22 16:03 123.txt ->
/root/123
.txt
-rw-r--r-- 1 root root 0 Apr 22 16:02 2
-rw-r--r-- 1 root root 0 Apr 22 16:02 3
[root@yong test1]
# cd ..
|
1
2
3
4
5
6
7
|
[root@yong
rsync
]
# rsync -a test1 test2
[root@yong
rsync
]
# ls test2
test1
[root@yong
rsync
]
# ls
test1 test2
[root@yong
rsync
]
# ls test2/test1/
1 123.txt 2 3
|
1
2
3
4
5
|
[root@yong
rsync
]
# rsync -a test1/ test2/
[root@yong
rsync
]
# ls
test1 test2
[root@yong
rsync
]
# ls test2/
1 123.txt 2 3
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@yong
rsync
]
# rsync -av --no-l test1/ test2/
sending incremental
file
list
created directory test2
./
1
skipping non-regular
file
"123.txt"
2
3
sent 200 bytes received 72 bytes 544.00 bytes
/sec
total size is 13 speedup is 0.05
[root@yong
rsync
]
# ls
test1 test2
[root@yong
rsync
]
# ls -l test2/
total 0
-rw-r--r-- 1 root root 0 Apr 22 16:02 1
-rw-r--r-- 1 root root 0 Apr 22 16:02 2
-rw-r--r-- 1 root root 0 Apr 22 16:02 3
|
1
2
3
4
5
6
7
8
9
10
|
[root@yong
rsync
]
# rsync -avL test1/ test2/
sending incremental
file
list
created directory test2
./
1
123.txt
2
3
sent 231 bytes received 91 bytes 644.00 bytes
/sec
total size is 0 speedup is 0.00
|
1
2
3
4
5
6
|
[root@yong
rsync
]
# ls -l test2/
total 0
-rw-r--r-- 1 root root 0 Apr 22 16:02 1
-rw-r--r-- 1 root root 0 Apr 22 16:03 123.txt
-rw-r--r-- 1 root root 0 Apr 22 16:02 2
-rw-r--r-- 1 root root 0 Apr 22 16:02 3
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@yong
rsync
]
# ll test1/1 test2/1
-rw-r--r-- 1 root root 0 Apr 22 16:02 test1
/1
-rw-r--r-- 1 root root 0 Apr 22 16:02 test2
/1
[root@yong
rsync
]
# touch test2/1
[root@yong
rsync
]
# ll test1/1 test2/1
-rw-r--r-- 1 root root 0 Apr 22 16:02 test1
/1
-rw-r--r-- 1 root root 0 Apr 22 16:31 test2
/1
[root@yong
rsync
]
# rsync -av test1/1 test2/1
sending incremental
file
list
1
sent 65 bytes received 31 bytes 192.00 bytes
/sec
total size is 0 speedup is 0.00
[root@yong
rsync
]
# ll test1/1 test2/1
-rw-r--r-- 1 root root 0 Apr 22 16:02 test1
/1
-rw-r--r-- 1 root root 0 Apr 22 16:02 test2
/1
|
1
2
3
4
5
6
7
8
9
10
|
[root@yong
rsync
]
# touch test2/1
[root@yong
rsync
]
# ll test2/1
-rw-r--r-- 1 root root 0 Apr 22 16:37 test2
/1
[root@yong
rsync
]
# rsync -avu test1/1 test2/1
sending incremental
file
list
sent 26 bytes received 12 bytes 76.00 bytes
/sec
total size is 0 speedup is 0.00
[root@yong
rsync
]
# ll test2/1 test1/1
-rw-r--r-- 1 root root 0 Apr 22 16:02 test1
/1
-rw-r--r-- 1 root root 0 Apr 22 16:37 test2
/1
|
1
2
3
4
5
6
7
8
9
10
11
|
[root@yong
rsync
]
# rm -f test1/123.txt
[root@yong
rsync
]
# ls test1/
1 2 3
[root@yong
rsync
]
# rsync -av test1/ test2/
sending incremental
file
list
./
1
sent 94 bytes received 34 bytes 256.00 bytes
/sec
total size is 0 speedup is 0.00
[root@yong
rsync
]
# ls test2/
1 123.txt 2 3
|
1
2
3
4
5
6
7
|
[root@yong
rsync
]
# rsync -av --delete test1/ test2/
sending incremental
file
list
deleting 123.txt
sent 52 bytes received 12 bytes 128.00 bytes
/sec
total size is 0 speedup is 0.00
[root@yong
rsync
]
# ls test2/
1 2 3
|
1
2
3
4
5
6
|
[root@yong
rsync
]
# touch test1/aa
[root@yong
rsync
]
# rsync -a --exclude="aa" test1/ test2/
[root@yong
rsync
]
# ls test1/
1 2 3 aa
[root@yong
rsync
]
# ls test2/
1 2 3
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@yong
rsync
]
# touch test1/1.txt test1/2.txt
[root@yong
rsync
]
# rsync -a --progress --exclude="*.txt" test1/ test2/
sending incremental
file
list
./
aa
0 100% 0.00kB
/s
0:00:00 (xfer
#1, to-check=0/5)
sent 109 bytes received 34 bytes 286.00 bytes
/sec
total size is 0 speedup is 0.00
[root@yong
rsync
]
# ls test2/
1 2 3 aa
[root@yong
rsync
]
# ls test1/
1 1.txt 2 2.txt 3 aa
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[email protected]'s password:
sending incremental
file
list
created directory
/tmp/test2
./
1
1.txt
2
2.txt
3
aa
sent 336 bytes received 129 bytes 132.86 bytes
/sec
total size is 0 speedup is 0.00
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[email protected]'s password:
receiving incremental
file
list
created directory .
/test3
./
1
1.txt
2
2.txt
3
aa
sent 128 bytes received 329 bytes 130.57 bytes
/sec
total size is 0 speedup is 0.00
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
[root@yong ~]
# mkdir .ssh
[root@yong ~]
# ssh-keygen
Generating public
/private
rsa key pair.
Enter
file
in
which
to save the key (
/root/
.
ssh
/id_rsa
):
Enter passphrase (empty
for
no passphrase):
Enter same passphrase again:
Your identification has been saved
in
/root/
.
ssh
/id_rsa
.
Your public key has been saved
in
/root/
.
ssh
/id_rsa
.pub
.
The key fingerprint is:
ab:0e:83:11:69:69:34:d2:34:87:b8:07:40:36:e4:a3
The key's randomart image is:
+--[ RSA 2048]----+
|*O=.. |
|=o+* |
| =* |
|ooo. |
|E.. S |
| o . |
| . o . |
| o . |
| .o |
+-----------------+
[
root@yong ~]
# ls .ssh/
id_rsa id_rsa.pub
|
1
2
|
[root@yong ~]
# cat .ssh/id_rsa.pub
ssh
-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArLHpwzyzfPtjihx90
/vdl9HqtLfmpuNDGYL
+UWOcFAAul6PVz81fb
/0RSAAPSu1Q3UdBWXlTqPUH4JucwaxYW
+obW
/zmteuZRaGf06iY01cj/Nr74ML0792cvfjCU87FyEH
+ZcvNhgRU+iTo+ES0kkLEuHV1x3JJLOhgYzIU0RtuU3CRiFxPHo92jNjpOs66YW3TbOX0AEB47WoRmKThiQVwoU7Lwqpl
/N7vQHtdj9vPtsVZsguKlCB5a2YoxRpnbdn8a5jdzVKuy
+hBrdfP
/1NkmVU9mBTV/f0b
+is5uHmQqNVAQW5fIi7QdVWG8HuyQliOXZUxoxGPCAjCuNy+dw== [email protected]
|
1
2
3
4
|
[root@localhost ~]
# mkdir .ssh
[root@localhost ~]
# chmod 700 .ssh/
[root@localhost ~]
# touch .ssh/authorized_keys
[root@localhost ~]
# vi .ssh/authorized_keys
|
1
2
3
4
5
6
7
8
|
[root@yong ~]
# ssh [email protected]
The authenticity of host
'192.168.20.10 (192.168.20.10)'
can't be established.
RSA key fingerprint is 84:47:af:bf:11:69:43:aa:
bc
:fe:9b:d6:08:b4:c4:1a.
Are you sure you want to
continue
connecting (
yes
/no
)?
yes
Warning: Permanently added
'192.168.20.10'
(RSA) to the list of known hosts.
Last login: Wed Apr 22 19:35:40 2015 from 192.168.20.1
[root@localhost ~]
# hostname
localhost.localdomain
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@localhost ~]
# exit
logout
Connection to 192.168.20.10 closed.
[root@yong ~]
# rsync -av rsync/test1/ [email protected]:/tmp/test3/
sending incremental
file
list
created directory
/tmp/test3
./
1
1.txt
2
2.txt
3
aa
sent 336 bytes received 129 bytes 310.00 bytes
/sec
total size is 0 speedup is 0.00
|
1
2
3
4
|
[root@localhost ~]
# vi /etc/ssh/sshd_config
[root@localhost ~]
# service sshd restart
停止 sshd: [确定]
正在启动 sshd:
|
1
2
3
|
[root@yong ~]
# telnet 192.168.20.10 22
Trying 192.168.20.10...
telnet: connect to address 192.168.20.10: Connection refused
|
1
2
3
4
|
[root@yong ~]
# rsync -av rsync/test1/ [email protected]:/tmp/test2/
ssh
: connect to host 192.168.20.10 port 22: Connection refused
rsync
: connection unexpectedly closed (0 bytes received so far) [sender]
rsync
error: error
in
rsync
protocol data stream (code 12) at io.c(600) [sender=3.0.6]
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@yong ~]
# rsync -av "--rsh=ssh -p 222" rsync/test1/ [email protected]:/tmp/test2/
sending incremental
file
list
created directory
/tmp/test2
./
1
1.txt
2
2.txt
3
aa
sent 336 bytes received 129 bytes 310.00 bytes
/sec
total size is 0 speedup is 0.00
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@localhost
rsync
]
# cat /etc/rsyncd.conf
#port=873
log
file
=
/var/log/rsync
.log
pid
file
=
/var/run/rsyncd
.pid
#address=192.168.20.10
[
test
]
path=
/tmp/rsync
use chroot=
true
max connections=4
read
only=no
list=
true
uid=root
gid=root
#auth users=test
#secrets file=/etc/rsyncd.passwd
hosts allow=192.168.20.0
/24
|
1
2
3
4
5
6
7
|
[root@localhost tmp]
# rsync --daemon
[root@localhost tmp]
# ps aux |grep rsync
root 1583 0.0 0.1 6232 644 ? Ss 14:49 0:00
rsync
--daemon
root 1585 0.0 0.1 5976 740 pts
/0
S+ 14:50 0:00
grep
rsync
[root@localhost tmp]
# netstat -nlp |grep rsync
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1583
/rsync
tcp 0 0 :::873 :::* LISTEN 15
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
sending incremental
file
list
created directory
/test
./
1
0 100% 0.00kB
/s
0:00:00 (xfer
#1, to-check=8/10)
1.txt
1076 100% 0.00kB
/s
0:00:00 (xfer
#2, to-check=7/10)
2
0 100% 0.00kB
/s
0:00:00 (xfer
#3, to-check=6/10)
2.txt
0 100% 0.00kB
/s
0:00:00 (xfer
#4, to-check=5/10)
3
0 100% 0.00kB
/s
0:00:00 (xfer
#5, to-check=4/10)
aa
0 100% 0.00kB
/s
0:00:00 (xfer
#6, to-check=3/10)
tree
36464 100% 1.93MB
/s
0:00:00 (xfer
#7, to-check=2/10)
a1/
b1/
sent 37992 bytes received 152 bytes 3632.76 bytes
/sec
total size is 37540 speedup is 0.98
|
1
2
|
[root@localhost
rsync
]
# ls test/
1 1.txt 2 2.txt 3 a1 aa b1 tree
|
1
2
3
4
5
6
7
8
|
[root@yong
rsync
]
# rsync -avL --progress 192.168.20.10::test/abc ./
receiving incremental
file
list
abc
0 100% 0.00kB
/s
0:00:00 (xfer
#1, to-check=0/1)
sent 45 bytes received 94 bytes 13.24 bytes
/sec
total size is 0 speedup is
|