linux下ssh普通用户后自动切换root
#!/bin/bash
i=`echo $1 | awk -F. ‘{print $3}‘`
j=`echo $1 | awk -F. ‘{print $2}‘`
case $j in
18)
cat > /tmp/qt.expect << EOF
#!/usr/bin/expect
set ip [lindex \$argv 0]
spawn ssh taomee@\$ip
expect "*password:*" { send "pass_word\r" }
expect "*\$*" { send "su -\r" }
expect "*Password:*" { send "pass_word\r" }
expect "*#*" { send "clear\r" }
interact
EOF
chmod +x /tmp/qt.expect
/tmp/qt.expect $1
rm -rf /tmp/qt.expect
;;
168)
case $i in
20)
cat > /tmp/tj.expect << EOF
#!/usr/bin/expect
set ip [lindex \$argv 0]
spawn ssh taomee@\$ip
expect "*password:*" { send "pass_word\r" }
expect "*\$*" { send "su -\r" }
expect "*Password:*" { send "pass_word\r" }
expect "*#*" { send "clear\r" }
interact
EOF
chmod +x /tmp/tj.expect
/tmp/tj.expect $1
rm -rf /tmp/tj.expect
;;
*)
echo "I don‘t kown its password"
;;
esac
;;
*)
echo "I don‘t kown its password"
;;
esac
PS:shell加密方法,编译二进制~~~
wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.6.tgz
本文出自 “LinuxDream” 博客,请务必保留此出处http://books.blog.51cto.com/2600359/1395776
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。