***GSSAPI是公共安全事务应用程序接口(GSS-API)
公共安全事务应用程序接口以一种统一的模式为使用者提供安全事务,由于它支持最基本的机制和技术,所以保证不同的应用环境下的可移植性.
该规范定义了GSS-API事务和基本元素,并独立于基本的机制和程序设计语言环境,并借助于其它相关的文档规范实现。
如果我们在服务端打开GSSAPIAuthentication配置项
在客户端登录服务端会用gssapi-keyex,gssapi-with-mic进行身份校验
(前提是服务器和客户端都开启这个功能)
**************************
sshd 的配置
生成密钥对: ssh-keygen
查看密钥对: /root/.ssh/ 这个目录下
拷贝密钥: ssh-copy-id root@ip
密钥的操作详细过程:
如果你的系统里面安装了ssh
[iyunv@www ~]# ssh (连续敲击2次tab 可以实现命令搜索(一般用于命令补全)
ssh ssh-add ssh-agent ssh-copy-id sshd ssh-keygen ssh-keyscan
这里我用到的命令是 ssh-keygen ==>生成密钥对 ssh-copy-id ===>给对方发送认真密钥
1.生成密钥:
[iyunv@www ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y #####这里会出现这个是因为我之前练习过。需要覆盖。
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:
97:17:1f:7e:d9:c1:a7:71:49:e1:e7:0f:ca:f7:60:4c root@www
The key's randomart image is:
+--[ RSA 2048]----+
| o.|
| + .|
| . o=+|
| . + **|
| S o . E.+|
| . o + o.|
| o = .|
| o o |
| .|
+-----------------+
2.查看 执行情况
[iyunv@www ~]# ls /root/.ssh
id_rsa id_rsa.pub known_hosts
当然也可以通过这个查看
[iyunv@www ~]# echo $?
0
通过检查命令执行的返回结果查看。如果是0正常。非0,则需要好好查看排错。
3.传递密钥,并且查看结果
[iyunv@www ~]# ssh-copy-id root@192.168.1.151 root@192.168.1.151's password:
Now try logging into the machine, with "ssh 'root@192.168.1.151'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
给出的信息大概意思是:试试 "ssh 'root@192.168.1.151'" 。看authorized_keys是否生效。
看下是不是很意外:不输入密码也可以登录。
[iyunv@www ~]# ssh root@192.168.1.151
Last login: Fri Jan 13 08:13:55 2017 from 192.168.1.123
[iyunv@jf6 ~]#
结果:测试成功。又补习了一下ssh 的知识。
实战:使用rsync进行数据同步
命令意思 参数 作用 局限性
格式: rsync 【选项】 源文件 目标文件
常见的选项:
-a --archive (存档)归档模式,表示以递归的方式传输文件,并且保持文件属相,等同于
加了参数 - r l p t g o D ******************
-r --recursive 对子目录以递归模式处理。
-l --link表示拷贝链接文件
-p --perm 表示 保持文件原有权限
-t --times 表示保持文件原有时间
-g --group 表示保持文件原有用户组
-o --owner 表示保持文件原有属主
-D --devices 表示块设备文件信息
-z --compress 表示压缩传输
-H 表示硬链接文件
-A 保留ACL属性信息
-P 显示传输进度 **************
(增量备份) --delete 删除哪些目标位置有而原始位置没有的文件。**************
无交互备份模拟;备份 oldboy /var/www/html 目录到 jf 的/web-back
# rsync -azP /var/www/html user@ip:/
操作实例:(ssh的密码交互在前面已经做好了)
[iyunv@www ~]# mkdir -p /var/www/html
[iyunv@www ~]# cp -r /boot/* /var/www/html/ (不加-r 不拷贝目录)如果不想重复输入/var/www/html(可以按esc+.重复上次命令最后参数)
[iyunv@www ~]# ssh 192.168.1.151
Last login: Fri Jan 13 08:30:06 2017 from 192.168.1.123
[iyunv@jf6 ~]# ls /web-back
ls: cannot access /web-back: No such file or directory
[iyunv@www ~]# rsync -azP --delete /var/www/html/* root@192.168.1.151:/web-back
sending incremental file list
created directory /web-back
。。。。。。由于加了P 选项所以显示进度这里略去。。。。。。。
sent 54299622 bytes received 529 bytes 5715805.37 bytes/sec
total size is 59172855 speedup is 1.09
[iyunv@www ~]# ssh root@192.168.1.151
Last login: Fri Jan 13 08:51:58 2017 from 192.168.1.123
[iyunv@jf6 ~]# ls /web-back/
config-2.6.32-504.el6.x86_64 symvers-2.6.32-504.el6.x86_64.gz
config-2.6.32-642.11.1.el6.x86_64 symvers-2.6.32-642.11.1.el6.x86_64.gz
efi System.map-2.6.32-504.el6.x86_64
grub System.map-2.6.32-642.11.1.el6.x86_64
initramfs-2.6.32-504.el6.x86_64.img vmlinuz-2.6.32-504.el6.x86_64
initramfs-2.6.32-642.11.1.el6.x86_64.img vmlinuz-2.6.32-642.11.1.el6.x86_64
lost+found
测试结果:实现了无交互式备份。
创建脚本;
#!/bin/bash
inotifywait -mrq -e create,move,delete,modify /var/www/html |while read a b c
do
rsync -azP --delete /var/www/html/ root@ip:/web-back
done
运行脚本: sh x.sh