1.安装系统

安装系统时如果引导盘路径不对,需要修改

一般插入U盘后,出现如下三行
1. install Centos 7
2. Test This media & install Centos 7
3. Troubleshoooting
此时,tab建 编辑第一个 将会出现以下文字

vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet

修改为
vmlinuz initrd=initrd.img linux dd quiet
ctrl + x 执行,获得u盘盘符(可能要r命令刷新)
重启

启动命令修改为
vmlinuz initrd=initrd.img inst.stage2=hd:/dev/u盘盘符 quiet
ctrl + x 执行,进入系统安装流程

  参考:https://blog.csdn.net/qq_38386316/article/details/78733995

 

2.修改电源模式

配置为合盖关显示器不休眠
vi /etc/systemd/logind.conf

HandleLidSwitch=lock

保存,重启服务
systemctl restart systemd-logind

  参考https://blog.csdn.net/m0_37710388/article/details/91171853

ubuntu

systemctl restart systemd-logind.service

 

3.为各个账户添加秘钥

将已有ssh文件夹拷贝到指定位置

  

4.为普通账户添加切root权限

echo "duser ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/duser
chmod 0440 /etc/sudoers.d/duser

  

5.修改ssh配置文件

vi /etc/ssh/sshd_config

PermitRootLogin yes => PermitRootLogin no
PasswordAuthentication yes => PasswordAuthentication no
Port 22 => Port 20000
#ClientAliveInterval 180 => ClientAliveInterval 180
#ClientAliveCountMax 3 => ClientAliveCountMax 3

保存,重启服务
systemctl restart sshd.service

  

 

6.修改静态ip

vi /etc/sysconfig/network-scripts/ifcfg-网卡

BOOTPROTO=static
IPV6INIT=no
ONBOOT=yes
IPADDR=192.168.0.10
PREFIX=24
GATEWAY=192.168.0.1
DNS1=114.114.114.114

保存,重启
systemctl restart network

有时候还要关闭重启无线wifi

ubuntu20

安装ssh

cat /etc/netplan/01-network-manager-all.yaml

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    eno1:
      dhcp4: no
      dhcp6: no
      addresses: [10.23.24.14/23]
      gateway4: 10.23.24.1
      nameservers:
        addresses: [10.23.24.1,114.114.114.114]

 

7.(可选) 外网登录

与外网机交换秘钥
yum install -y autossh
mkdir -p /data/autossh
touch /data/autossh/1.sh
echo "nohup autossh -p9999  root@123.123.123.123 -NR 10003:localhost:22 -M 23999 &" > /data/autossh/1.sh
cd /data/autossh
sh 1.sh

  

8.添加到系统服务,方便管理(ubuntu20)

cd /etc/systemd/system/ && vim autossh.service

[Unit]
Description=Front autossh
After=sshd.target
[Service]
User=root
Type=simple
ExecStart=/usr/bin/autossh -p9999  root@123.123.123.123 -NR 10003:localhost:22 -M 23999
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
[Install]
WantedBy=multi-user.target

启停autossh

systemctl stop|start|status|enable|disable autossh.service

 

 
posted on 2020-09-24 23:23  芒果-Vic  阅读(195)  评论(0编辑  收藏  举报