|
- 开发使用linux乌班图的系统,没有类似SecureCRT的工具,每次登陆linux系统都需要输入密码,
很浪费时间。于是弄了一个脚本让他们每次都直接输入一个服务器别名就能登陆linux系统。以下
是具体操作步骤:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| 1.vim /root/expect_ssh.exp
#!/usr/bin/expect -f
set timeout 99
set host [lindex $argv 0]
set port [lindex $argv 1]
set username [lindex $argv 2]
set password [lindex $argv 3]
spawn ssh -p $port $username@$host
expect {
"yes" {send "yes\r";exp_continue}
"*assword" {send "$password\r"}
}
expect "from"
interact
2.别名设置vim .bashrc
alias server1='expect -f /root/expect_ssh.exp 1.1.1.1 22 root "123456"'
3.刷新 .bashrc 环境变量
source /root/.bashrc
4.在linux系统使用server1别名登陆系统,到此1.1.1.1 服务器就能实现在乌班图系统的自动登陆了。
|
|
|
|
|
|
|
|