安装教程比较多就不写了。
网络配置
设置虚拟网络
修改网络配置文件
vi /etc/sysconfig/network-scripts/ifcfg-ens33
将ONBOOT由no改为yes:
修改为静态网络
/etc/sysconfig/network-scripts/ifcfg-eth33
BOOTPROTO=static
IPADDR=192.168.1.129
GATEWAY=192.168.1.2
DNS1=8.8.8.8
DNS2=114.114.114.114
添加dns服务器
在此要强调一点的是,直接修改/etc/resolv.conf这个文件是没用的,网络服务重启以后会根据/etc/sysconfig /network-scripts/ifcfg-eth33来重载配置
我们上面加了就不用改了
vi /etc/resolv.conf
添加首选DNS服务器和备选DNS服务器。
nameserver 8.8.8.8
nameserver 114.114.114.114
重启网络服务
service network restart
关闭防火墙
虚拟机放心关掉
#暂时关闭防火墙
systemctl stop firewalld
#永久关闭防火墙
systemctl disable firewalld
配置镜像源
备份yum源(可选)
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
修改
中科大
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
-i.bak \
/etc/yum.repos.d/CentOS-Base.repo
阿里云
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清理缓存
yum makecache
软件安装
Vim
yum -y install vim
wget
yum -y install wget
安装net-tools
yum search net-tools#先查找在安装
yum install -y net-tools.x86_64
更新系统
yum update -y
ssh
烦死了,改了一个上午,好多教程都没啥用。
可能出现的问题
- channel is not opened.
- 连接半天,密码没错但是出现要输入密码
解决
首先看ssh是否安装,这个一般都还是有的。
yum list installed | ssh
主要看配置.
PermitRootLogin改为yes
PasswordAuthentication改为yes
UseDNS改为 no
UsePAM 改为yes
重启ssh
systemctl restart sshd.service
配置文件
/etc/ssh/sshd_config
1 # $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
2
3 # This is the sshd server system-wide configuration file. See
4 # sshd_config(5) for more information.
5
6 # This sshd was compiled with PATH=/usr/local/bin:/usr/bin
7
8 # The strategy used for options in the default sshd_config shipped with
9 # OpenSSH is to specify options with their default value where
10 # possible, but leave them commented. Uncommented options override the
11 # default value.
12
13 # If you want to change the port on a SELinux system, you have to tell
14 # SELinux about this change.
15 # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
16 #
17 #Port 22
18 #AddressFamily any
19 #ListenAddress 0.0.0.0
20 #ListenAddress ::
21
22 HostKey /etc/ssh/ssh_host_rsa_key
23 #HostKey /etc/ssh/ssh_host_dsa_key
24 HostKey /etc/ssh/ssh_host_ecdsa_key
25 HostKey /etc/ssh/ssh_host_ed25519_key
26
27 # Ciphers and keying
28 #RekeyLimit default none
29
30 # Logging
31 #SyslogFacility AUTH
32 SyslogFacility AUTHPRIV
33 #LogLevel INFO
34
35 # Authentication:
36
37 #LoginGraceTime 2m
38 PermitRootLogin yes
39 #StrictModes yes
40 #MaxAuthTries 6
41 #MaxSessions 20
42
43 #PubkeyAuthentication yes
44
45 # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
46 # but this is overridden so installations will only check .ssh/authorized_keys
47 AuthorizedKeysFile .ssh/authorized_keys
48
49 #AuthorizedPrincipalsFile none
50
51 #AuthorizedKeysCommand none
52 #AuthorizedKeysCommandUser nobody
53
54 # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
55 #HostbasedAuthentication no
56 # Change to yes if you don't trust ~/.ssh/known_hosts for
57 # HostbasedAuthentication
58 #IgnoreUserKnownHosts no
59 # Don't read the user's ~/.rhosts and ~/.shosts files
60 #IgnoreRhosts yes
61
62 # To disable tunneled clear text passwords, change to no here!
63 #PasswordAuthentication yes
64 #PermitEmptyPasswords no
65 PasswordAuthentication yes
66
67 # Change to no to disable s/key passwords
68 #ChallengeResponseAuthentication yes
69 ChallengeResponseAuthentication no
70
71 # Kerberos options
72 #KerberosAuthentication no
73 #KerberosOrLocalPasswd yes
74 #KerberosTicketCleanup yes
75 #KerberosGetAFSToken no
76 #KerberosUseKuserok yes
77
78 # GSSAPI options
79 GSSAPIAuthentication yes
80 GSSAPICleanupCredentials no
81 #GSSAPIStrictAcceptorCheck yes
82 #GSSAPIKeyExchange no
83 #GSSAPIEnablek5users no
84
85 # Set this to 'yes' to enable PAM authentication, account processing,
86 # and session processing. If this is enabled, PAM authentication will
87 # be allowed through the ChallengeResponseAuthentication and
88 # PasswordAuthentication. Depending on your PAM configuration,
89 # PAM authentication via ChallengeResponseAuthentication may bypass
90 # the setting of "PermitRootLogin without-password".
91 # If you just want the PAM account and session checks to run without
92 # PAM authentication, then enable this but set PasswordAuthentication
93 # and ChallengeResponseAuthentication to 'no'.
94 # WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
95 # problems.
96 UsePAM yes
97
98 #AllowAgentForwarding yes
99 #AllowTcpForwarding yes
100 #GatewayPorts no
101 X11Forwarding yes
102 #X11DisplayOffset 10
103 #X11UseLocalhost yes
104 #PermitTTY yes
105 #PrintMotd yes
106 #PrintLastLog yes
107 #TCPKeepAlive yes
108 #UseLogin no
109 #UsePrivilegeSeparation sandbox
110 #PermitUserEnvironment no
111 #Compression delayed
112 #ClientAliveInterval 0
113 #ClientAliveCountMax 3
114 #ShowPatchLevel no
115 UseDNS no
116 #PidFile /var/run/sshd.pid
117 #MaxStartups 10:30:100
118 #PermitTunnel no
119 #ChrootDirectory none
120 #VersionAddendum none
121
122 # no default banner path
123 #Banner none
124
125 # Accept locale-related environment variables
126 AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
127 AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
128 AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
129 AcceptEnv XMODIFIERS
130
131 # override default of no subsystems
132 Subsystem sftp /usr/libexec/openssh/sftp-server
133
134 # Example of overriding settings on a per-user basis
135 #Match User anoncvs
136 # X11Forwarding no
137 # AllowTcpForwarding no
138 # PermitTTY no
139 # ForceCommand cvs server