MENU

centos7物理机安装配置

February 7, 2021 • linux相关

配置ip地址

编辑配置 /etc/sysconfig/network-scripts/ifcfg-ens33

#> vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp3s0
UUID=2118d236-42e7-4af0-a287-15f7491852e9
DEVICE=enp3s0
ONBOOT=yes
IPV6_PRIVACY=no

ONBOOT=no 改为 ONBOOT=yes 保存
重启网络:

service network restart

查看本机IP:

ifconfig -a

开启远程 ssh 登录

  1. 查看 openssh-server 服务是否安装(默认安装)

    #> yum list installed|grep openssh
    openssh.x86_64                        7.4p1-21.el7                     @anaconda
    openssh-clients.x86_64                7.4p1-21.el7                     @anaconda
    openssh-server.x86_64                 7.4p1-21.el7                     @anaconda

    未安装先安装:yum -y install openssh-server

  2. 编辑 /etc/ssh/sshd_config 配置文件:

    #> vim /etc/ssh/sshd_config
    Port 22
    #AddressFamily any
    ListenAddress 0.0.0.0
    ListenAddress ::
    ...
    PermitRootLogin yes
    ...
    PasswordAuthentication yes
    ...

    重启 sshd 服务:

    #> service sshd start

    检查:

    #> ps -e | grep sshd
     1137 ?        00:00:00 sshd
     2166 ?        00:00:00 sshd
    #> netstat -an|grep 22
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
    tcp6       0      0 :::22                   :::*                    LISTEN

    普通用户添加 sudo 操作

    #> visudo
    root    ALL=(ALL)       ALL
    user1   ALL=(ALL)       ALL
Last Modified: July 10, 2021