(CentOS)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

烦死了,改了一个上午,好多教程都没啥用。

可能出现的问题

  1. channel is not opened.
  2. 连接半天,密码没错但是出现要输入密码

解决

首先看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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一只小余

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值