虚拟机环境准备

1.下载centos7.6镜像,并安装

https://archive.kernel.org/centos-vault/7.6.1810/isos/x86_64/
image

2.网卡1选择nat

image
网卡配置文件
image

enp0s3

DEVICE=enp0s3
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp

3.网卡2选择仅主机网络

image
网卡配置文件
image
enp0s8

DEVICE=enp0s8
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.56.2
NETMASK=255.255.255.0
GATEWAY=192.168.56.1

4.本地虚拟网卡配置

image
image

5.宿主机关闭防火墙

image

6.虚拟机关闭selinux及防火墙

image

7.虚拟机sshd优化,关闭dns解析

vim /etc/ssh/sshd_config

GSSAPIAuthentication no
UseDNS no

systemctl restart sshd.service
完整sshd_config配置文件

[root@localhost ~]# cat /etc/ssh/sshd_config | grep -v '^#' | sed '/^$/d'
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
SyslogFacility AUTHPRIV
AuthorizedKeysFile	.ssh/authorized_keys
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication no
GSSAPICleanupCredentials no
UsePAM yes
X11Forwarding yes
UseDNS no
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
Subsystem	sftp	/usr/libexec/openssh/sftp-server
原创:做时间的朋友
原文地址:https://www.cnblogs.com/PythonOrg/p/15496243.html