iTerm2快速连接

    选择打赏方式

vim  ~/login.exp


#!/usr/bin/expect

if {$argc < 2} {
    #do something
    send_user "usage: $argv0 < <remote_host> <passwd>"
    exit
}

set timeout 3
set remote_host [lindex $argv 0]
set passwd [lindex $argv 1]

# 远程登录

spawn ssh kylin@${remote_host}

#yes/no

expect "*yes/no*"  {send "yes\r"}

#输入密码

expect "*assword:" {send "${passwd}\r"}

#切换root

expect "*$*" {send "sudo -i\r"}

#输入密码

expect "*assword for kylin:" {send "${passwd}\r"}

expect "*root@*" {send "clear\r"}

expect "*root@*" {send "cd /home/kylin\r"}

expect "*/home/kylin#" {send "kubectl get ns\r"}

expect "*/home/kylin#" {send "ls\r"}

interact

#expect eof

依次打开 iTerm-Profiles-Open Profiles-Edit Profiles- +

Xnip2020-08-18_11-30-00.jpg

版权声明:若无特殊注明,本文皆为《 zuoer 》原创,转载请保留文章出处。
本文链接:iTerm2快速连接 https://www.zuoer.xin/?post=111
正文到此结束

热门推荐

管理员已关闭本篇文章评论!