一、 两台服务器免密登录:
1. 生成密钥
ssh-keygen的命令手册,通过”man ssh-keygen“命令查看指令:
通过命令”ssh-keygen -t rsa“创建一对密匙,包括公匙和私匙,生成之后会在用户的根目录生成一个 “.ssh”的文件夹
进入“.ssh”,查看生成的文件
authorized_keys:存放远程免密登录的公钥,主要通过这个文件记录多台机器的公钥
id_rsa : 生成的私钥文件
id_rsa.pub : 生成的公钥文件
know_hosts : 已知的主机公钥清单
如果希望ssh公钥生效需满足至少下面两个条件:
1) .ssh目录的权限必须是700
2) .ssh/authorized_keys文件权限必须是600
常用以下几种方法:
2.1 通过ssh-copy-id的方式
命令: ssh-copy-id -i ~/.ssh/id_rsa.put <romte_ip>
举例:
[root@test .ssh]# ssh-copy-id -i ~/.ssh/id_rsa.pub 132.232.138.29
[root@test .ssh]# ssh root@ 132.232.138.29 直接连接另一台服务器就行了
2.2 通过scp将内容写到对方的文件中
命令:scp -p ~/.ssh/id_rsa.pub root@<remote_ip>:/root/.ssh/authorized_keys
scp: 即,ssh-copy-id
举例:
1. scp -p ~/.ssh/id_rsa.pub root@132.232.138.29 :/root/.ssh/authorized_keys
2. ssh root@192.168.91.135 直接连接另一台服务器就行了
原文参考地址:http://www.cnblogs.com/LuisYang/archive/2016/10/12/5952871.html
ntpdate ntp1.aliyun.com 根据阿里云服务器矫正时间
ntp:Network time Protocol,网络时间协议
# 测试sed命令
测试通过sed实现过滤匹配文本行之间的内容
匹配行后添加内容,并引用匹配模式。
##测试环境,文本内容如下:
```
[root@test sed_test]# cat test.txt1
this is a test1.
this is a test2.
this is a test3.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#
```
##测试p
###打印1行
```
[root@test sed_test]# sed '/test2/p' test.txt1
this is a test1.
this is a test2.
this is a test2.
this is a test3.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#
```
###打印多行
```
[root@test sed_test]# sed '2,3p' test.txt1
this is a test1.
this is a test2.
this is a test2.
this is a test3.
this is a test3.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#
```
##测试d删除
###删除单行
```
[root@test sed_test]# sed '/test2/d' test.txt1
this is a test1.
this is a test3.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#
```
###删除多行
```
[root@test sed_test]# sed '2,3d' test.txt1
this is a test1.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#
[root@test sed_test]# sed '2,4d' test.txt1
this is a test1.
this is a test5.
this is a test6.
[root@test sed_test]#
```
awk:
cat data|awk '{sum+=$1} END {print "Sum = ", sum}'
2、求平均值
cat data|awk '{sum+=$1} END {print "Average = ", sum/NR}'
3、求最大值
cat data|awk 'BEGIN {max = 0} {if ($1>max) max=$1 fi} END {print "Max=", max}'
4、求最小值(min的初始值设置一个超大数即可)
cat data | awk 'BEGIN {min = 1999999} {if ($1<min) min=$1 fi} END {print "Min=", min}'
haha 100
cost 100
[root@dplinux-node1 sed_awk]#
VMWare虚拟机IP为127.0.0.1的问题
dhclient -v