linux 帐号便捷登陆

核心

如设置便捷su

#!/usr/bin/expect -f

set port port_no
set user st_mchri_bigdata
set password Genomics20210
set timeout -1

spawn su $user
expect "*assword:*"

send "$password\r"

interact

  

便捷ssh登陆帐号

#! /usr/bin/expect

# set your login information
set user lizhichao
set ipaddress 192.168.6
set passwd li

#get the verfication code from local host
set code [exec sh -c {curl -s "http://localhost:17304"|grep -Eo "\d{6}"}] #Golden passport for verfication

set timeout -1

#login, request password and vertification code
spawn ssh lizhichao@192.168.6
expect "*assword:*"
send "$passwd\r"
expect "*erification code:*"
send "$code\r"

interact

  

核心函数 

set 设置shell

spawn 执行命令

 

posted on 2022-01-21 17:35  BioinformaticsMaster  阅读(48)  评论(0编辑  收藏  举报

导航