20200911 -
这里记录一些平时使用的脚本,免密登陆什么的。

免密登陆

#! /bin/bash

[ ! -f /root/.ssh/id_rsa.pub ] && ssh-keygen -t rsa -P '' -f /root/.ssh/id_rsa &>/dev/null

expect -c "
        spawn ssh-copy-id -i /root/.ssh/id_rsa.pub $1
        expect {
                \"*yes/no*\" {send \"yes\r\";exp_continue}
                \"*assword*\" {send \"inet_store@2018\r\"}
        }
        expect eof
"

开机自动启动

参考《CENTOS7开机自启动脚本
直接在/etc/rc.local/添加

/bin/bash xxx.sh >/dev/null 2>/dev/null

注意,这里的脚本一定要进入到需要的绝对路径中才行;同时要赋予rc.local执行权限。

Logo

一站式 AI 云服务平台

更多推荐