分类 甲骨文云 下的文章

vi /etc/systemd/system/obtain-ipv6.service

[Unit]
Description=Auto Obtain IPV6 Address
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/obtain-ipv6.sh start
ExecStop=/usr/bin/obtain-ipv6.sh stop
ExecReload=/usr/bin/obtain-ipv6.sh reload

[Install]
WantedBy=multi-user.target

systemctl enable obtain-ipv6.service
vi /usr/bin/obtain-ipv6.sh

#!/bin/bash
if [ $1 == "start" ];then
    dhclient -6 ens3
elif [ $1 == "STOP" ];then
    dhclient -6 -r
elif [ $1 == "reload" ];then
    dhclient -6 -r
    dhclient -6 ens3
fi

chmod u+x /usr/bin/obtain-ipv6.sh

创建实例
映像:CentOS 7
保存私有密钥

登陆
用户名:opc
用户密钥:选择保存的私钥

切换root:sudo -i
修改root密码:passwd root
修改opc密码:passwd opc

密钥登陆
vi /etc/ssh/sshd_config
禁用密码登陆:PasswordAuthentication no
禁用root登陆:PermitRootLogin no
重启ssh:systemctl restart sshd

修改私钥密码:ssh-keygen -f private_key -p

设置时区:timedatectl set-timezone Asia/Shanghai

启动时间:

date -d "$(awk -F. '{print $1}' /proc/uptime) second ago" +"system boot:%Y-%m-%d %H:%M:%S"

运行时间:

cat /proc/uptime | awk -F. '{run_days = $1 / 86400; run_hour = ($1 % 86400) / 3600; run_minute = ($1 % 3600) / 60; run_second = $1 % 60; printf("系统已运行:%d天%d时%d分%d秒\n", run_days, run_hour, run_minute, run_second)}'

0点重启:
vi /etc/crontab
0 0 * * * root reboot