CentOS7 相關配置記錄
阿新 • • 發佈:2022-04-06
配置IP
修改網絡卡配置檔案 vim /etc/sysconfig/network-scripts/ifcfg-eth0
(最後一個為網絡卡名稱)
動態獲取ip(前提是你的路由器已經開啟了DHCP)
動態獲取IP地址需要修改兩處地方即可
bootproto=dhcp
onboot=yes
設定靜態ip
bootproto=static
onboot=yes
# 在最後加上幾行,IP地址、子網掩碼、閘道器、dns伺服器
IPADDR=192.168.5.36
NETMASK=255.255.255.0
GATEWAY=192.168.5.1
DNS1=223.5.5.5
DNS2=8.8.8.8
最後需要重啟網路讓配置生效:
systemctl restart network
開啟ssh
- 安裝ssh
yum install openssh-server
- 配置ssh
vim /etc/ssh/sshd_config
# 開啟遠端ssh以root使用者密碼登入,預設為no,需要開啟root使用者訪問改為yes
PermitRootLogin yes
# 預設為no,改為yes開啟密碼登陸
PasswordAuthentication yes
# 讓配置生效
systemctl restart sshd.service
- 將ssh服務新增到自啟動列表中
systemctl enable sshd.service
- 啟動ssh
systemctl start sshd.service
- 檢視埠是否執行
netstat -an | grep 22