1. 配置网络环境
Centos7下载:
http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1708.iso
1.1. 配置ip地址:
[root@localhost85~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=c1fa9edb-773e-48d2-83cf-82e8b01ffbb0
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=00:0C:29:4E:A6:48
IPADDR=192.168.1.85
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth0
[root@localhost85~]#
1.2. 设置ip地址映射:
[root@localhost85~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4localhost4.localdomain4
::1 localhost localhost.localdomainlocalhost6 localhost6.localdomain6
192.168.1.85localhost85
~
[root@localhost85~]#
1.3. 设置主机名
[root@localhost85~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost85
GATEWAY=192.168.1.1
~
[root@localhost85~]#
1.4. 关闭selinux
[root@localhost85~]# vim /etc/selinux/config
# This file controlsthe state of SELinux on the system.
# SELINUX= can takeone of these three values:
# enforcing - SELinux security policy isenforced.
# permissive - SELinux prints warningsinstead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= cantake one of these two values:
# targeted - Targeted processes areprotected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost85~]#
1.5. 关闭防火墙
[root@localhost85~]#
[root@localhost85~]# iptables -F
[root@localhost85~]# /etc/init.d/iptables save #保存规则
iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定]
[root@localhost85~]#
[root@localhost85~]# chkconfig iptables off #开机关闭
[root@localhost85~]# chkconfig --list
[root@localhost85~]#reboot #重新启动
1.6. 生成ssh无秘钥登录
[root@localhost85~]#
[root@localhost85~]# ssh-keygen
Generatingpublic/private rsa key pair.
Enter file in whichto save the key (/root/.ssh/id_rsa):
Enter passphrase(empty for no passphrase):
Enter samepassphrase again:
Your identificationhas been saved in /root/.ssh/id_rsa.
Your public key hasbeen saved in /root/.ssh/id_rsa.pub.
The key fingerprintis:
13:f1:e5:a3:62:ac:ce:ad:63:72:d1:6f:4a:89:de:5broot@localhost85
The key's randomart imageis:
+--[ RSA 2048]----+
| . . |
| o o |
| . . o |
| . . . . |
| .S . |
| .+.+ |
| o.o.E |
| .+++ .o |
| +=o=+ |
+-----------------+
[root@localhost85~]#
[root@localhost85~]# ls /root/.ssh/
id_rsa id_rsa.pub known_hosts
[root@localhost85~]#
[root@localhost85~]#
[root@localhost85~]# ssh-copy-id -i /root/.ssh/id_rsa [email protected]
[email protected]'spassword:
Now try logging intothe machine, with "ssh '[email protected]'", and check in:
.ssh/authorized_keys
to make sure wehaven't added extra keys that you weren't expecting.
[root@localhost85~]#
[root@localhost85~]# ls /root/.ssh/
authorized_keys id_rsa id_rsa.pub known_hosts
[root@localhost85~]#
以上配置就可以通过ssh直接登录,不需要密码验证