我使用以下脚本来更改其中的.ssh目录和id_rsa.pub文件的权限。我已经将id_rsa.pub文件转移到远程主机,在这个脚本中,我正在使用bash中的expect更改文件夹.ssh及其中文件的权限
我的问题是,脚本根本没有回到本地提示符:
#!/usr/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
set timeout -1
set server [lindex $argv 0]
set user [lindex $argv 1]
set pass [lindex $argv 2]
spawn ssh $user@$server
expect -exact "password: "
send -- "$pass\r"
expect -exact "$ "
send -- "ls >> new.txt\r"
expect -exact "$ "
send -- "mkdir .ssh\r"
expect -exact "$ "
send -- "cat id_rsa.pub >> ~/.ssh/authorized_keys\r"
expect -exact "$ "
send -- "rm id_rsa.pub\r"
expect -exact "$ "
send -- "chmod go-w ~\r"
expect -exact "$ "
send -- "chmod 700 ~/.ssh\r"
expect -exact "$ "
send -- "chmod 600 ~/.ssh/authorized_keys\r"
expect -exact "$ "
send -- "logout\r"
我从一些bash文件中调用.ex文件,为许多用户在循环中生成必要的变量 请提供一些问题的解决方案
提前致谢....