美文网首页
Centos 7 mini 安装过程记录

Centos 7 mini 安装过程记录

作者: Devid | 来源:发表于2017-05-09 12:41 被阅读790次

    开启网络连接

    centos7 mini版本默认是无网络连接的。我们可以查看本地ip信息:

    [root@localhost ~]# ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:0c:29:ad:96:16 brd ff:ff:ff:ff:ff:ff
    [root@localhost ~]#
    
    

    查看网络配置文件

    [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
    TYPE=Ethernet
    BOOTPROTO=dhcp
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=eno16777728
    UUID=05d5a7d5-f16e-4492-9ea1-fa46b7134a8a
    DEVICE=eth0
    ONBOOT=no
    [root@localhost ~]#
    

    如果要开启DHCP,更新ifcfg-文件的 ONBOOT 值,从 no 改为 yes,保存并重启服务。

    [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
    

    结果如下

    TYPE=Ethernet
    BOOTPROTO=dhcp
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=eno16777728
    UUID=05d5a7d5-f16e-4492-9ea1-fa46b7134a8a
    DEVICE=eno16777728
    ONBOOT=yes
    

    重启网络服务

    [root@localhost ~]# service network restart
    Restarting network (via systemctl):                        [  OK  ]
    

    查看ip信息:

    [root@localhost ~]# ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:0c:29:ad:96:16 brd ff:ff:ff:ff:ff:ff
        inet 172.16.1.136/24 brd 172.16.1.255 scope global dynamic eno16777728
           valid_lft 1626sec preferred_lft 1626sec
        inet6 fe80::20c:29ff:fead:9616/64 scope link
           valid_lft forever preferred_lft forever
    

    如果你是固定ip,需要更新 ifcfg-eth0,添加静态地址IPADDR

    [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777728
    
    TYPE=Ethernet
    BOOTPROTO=none
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=eno16777728
    UUID=05d5a7d5-f16e-4492-9ea1-fa46b7134a8a
    DEVICE=eno16777728
    ONBOOT=yes
    DNS1=172.16.1.21
    DOMAIN=2factor.net
    IPADDR=172.16.1.25
    PREFIX=24
    GATEWAY=172.16.1.254
    

    重启网络服务

    [root@localhost ~]# service network restart
    Restarting network (via systemctl): [ OK ]
    

    参考:https://wiki.centos.org/FAQ/CentOS7#head-a21a9e454157700367c9b7e9ccb1ff9954bec881

    开启远程ssh

    CentOS7默认已经安装openssh-server,如果没有,执行安装命令如下;

    yum install openssh-server -y
    

    编辑ssh配置文件

    [root@centos-linux ~]# vim /etc/ssh/sshd_config
    

    开启如下配置:

    Port 22
    #AddressFamily any
    ListenAddress 0.0.0.0
    ListenAddress ::
    
    # The default requires explicit activation of protocol 1
    Protocol 2
    
    #RSAAuthentication yes
    PubkeyAuthentication yes
    
    # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
    # but this is overridden so installations will only check .ssh/authorized_keys
    AuthorizedKeysFile      .ssh/authorized_keys
    

    重启服务即可

    systemctl restart sshd.service
    

    关于ssh更多帮助:https://wiki.centos.org/HowTos/Network/SecuringSSH

    开启非root用户sudo提升权限的功能

    编辑文件/etc/sudoers
    首先增加sudoers文件写权限

    chmod 777 /etc/sudoers
    

    然后编辑此文件

    vi /etc/sudoers
    

    增加相关用户信息

    ## Allow root to run any commands anywhere
    root    ALL=(ALL)       ALL
    devid   ALL=(ALL)       ALL
    

    devid是我的用户名,保存文件即可。

    相关文章

      网友评论

          本文标题:Centos 7 mini 安装过程记录

          本文链接:https://www.haomeiwen.com/subject/zjbbtxtx.html