Linux安装后基础配置--网络--ssh--基本软件
安装教程比较多就不写了。
网络配置
设置虚拟网络
修改网络配置文件
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. See4 # sshd_config(5) for more information.5 6 # This sshd was compiled with PATH=/usr/local/bin:/usr/bin7 8 # The strategy used for options in the default sshd_config shipped with9 # OpenSSH is to specify options with their default value where10 # possible, but leave them commented. Uncommented options override the11 # default value.12 13 # If you want to change the port on a SELinux system, you have to tell14 # SELinux about this change.15 # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER16 #17 #Port 2218 #AddressFamily any19 #ListenAddress 0.0.0.020 #ListenAddress ::21 22 HostKey /etc/ssh/ssh_host_rsa_key23 #HostKey /etc/ssh/ssh_host_dsa_key24 HostKey /etc/ssh/ssh_host_ecdsa_key25 HostKey /etc/ssh/ssh_host_ed25519_key26 27 # Ciphers and keying28 #RekeyLimit default none29 30 # Logging31 #SyslogFacility AUTH32 SyslogFacility AUTHPRIV33 #LogLevel INFO34 35 # Authentication:36 37 #LoginGraceTime 2m38 PermitRootLogin yes39 #StrictModes yes40 #MaxAuthTries 641 #MaxSessions 2042 43 #PubkeyAuthentication yes44 45 # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys246 # but this is overridden so installations will only check .ssh/authorized_keys47 AuthorizedKeysFile .ssh/authorized_keys48 49 #AuthorizedPrincipalsFile none50 51 #AuthorizedKeysCommand none52 #AuthorizedKeysCommandUser nobody53 54 # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts55 #HostbasedAuthentication no56 # Change to yes if you don't trust ~/.ssh/known_hosts for57 # HostbasedAuthentication58 #IgnoreUserKnownHosts no59 # Don't read the user's ~/.rhosts and ~/.shosts files60 #IgnoreRhosts yes61 62 # To disable tunneled clear text passwords, change to no here!63 #PasswordAuthentication yes64 #PermitEmptyPasswords no65 PasswordAuthentication yes66 67 # Change to no to disable s/key passwords68 #ChallengeResponseAuthentication yes69 ChallengeResponseAuthentication no70 71 # Kerberos options72 #KerberosAuthentication no73 #KerberosOrLocalPasswd yes74 #KerberosTicketCleanup yes75 #KerberosGetAFSToken no76 #KerberosUseKuserok yes77 78 # GSSAPI options79 GSSAPIAuthentication yes80 GSSAPICleanupCredentials no81 #GSSAPIStrictAcceptorCheck yes82 #GSSAPIKeyExchange no83 #GSSAPIEnablek5users no84 85 # Set this to 'yes' to enable PAM authentication, account processing,86 # and session processing. If this is enabled, PAM authentication will87 # be allowed through the ChallengeResponseAuthentication and88 # PasswordAuthentication. Depending on your PAM configuration,89 # PAM authentication via ChallengeResponseAuthentication may bypass90 # the setting of "PermitRootLogin without-password".91 # If you just want the PAM account and session checks to run without92 # PAM authentication, then enable this but set PasswordAuthentication93 # and ChallengeResponseAuthentication to 'no'.94 # WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several95 # problems.96 UsePAM yes97 98 #AllowAgentForwarding yes99 #AllowTcpForwarding yes100 #GatewayPorts no101 X11Forwarding yes102 #X11DisplayOffset 10103 #X11UseLocalhost yes104 #PermitTTY yes105 #PrintMotd yes106 #PrintLastLog yes107 #TCPKeepAlive yes108 #UseLogin no109 #UsePrivilegeSeparation sandbox110 #PermitUserEnvironment no111 #Compression delayed112 #ClientAliveInterval 0113 #ClientAliveCountMax 3114 #ShowPatchLevel no115 UseDNS no116 #PidFile /var/run/sshd.pid117 #MaxStartups 10:30:100118 #PermitTunnel no119 #ChrootDirectory none120 #VersionAddendum none121 122 # no default banner path123 #Banner none124 125 # Accept locale-related environment variables126 AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES127 AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT128 AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE129 AcceptEnv XMODIFIERS130 131 # override default of no subsystems132 Subsystem sftp /usr/libexec/openssh/sftp-server133 134 # Example of overriding settings on a per-user basis135 #Match User anoncvs136 # X11Forwarding no137 # AllowTcpForwarding no138 # PermitTTY no139 # ForceCommand cvs server