首页 > 编程知识 正文

quickpcb2005视频教程,shell编程

时间:2023-05-06 14:32:26 阅读:111737 作者:1041

zbuz添加用户并批量分发ssh公钥脚本。 #! /bin/bash

./etc/init.d/functions

functionadd_user

jumper='$1'

useradd${jumper}

echo 123456|passwd---stdin $ { jumper }/dev/null 21

iftwdbg ` grep-o $ jumper/etc/passwd|WC-l `-gt1 ]

陈真

action ' adduser $ { jumper } success '/bin/true

else

操作' adduser $ { jumper } success failure '/bin/false

exit0

fi

su $ { jumper }-c ' ssh-keygen-tdsa-p '-f~/.ssh/id _ DSA/dev/null 21 '

iftwdbg$? -eq0]

then

操作' createsshpubkeysuccess '/bin/true

else

动作' createsshpubkeyfailure '/bin/false

fi

}

add_user$*

fornin78

do

/usr/bin/expect/server/scripts/fen fa _ key.exp/home/$ { jumper }/. ssh/id _ DSA.pub $ { jumper } 11。

iftwdbg$? -eq0]

then

action ' fenfasshpubkeyto 11.0.0.$ { n } success '/bin/true

else

action ' fenfasshpubkeyto 11.0.0.$ { n } failure '/bin/false

fi

通过doneexpect实现无密码认证#! /usr/bin/expect

if{$argc!=3}{

puts ' usage : expect $ argv0sshkeyuserhost '

退出

}

#定义虚拟机

setsshkeytwdbglindex$argv0]

setusertwdbglindex$argv1]

sethosttwdbglindex$argv2]

setpassword'123456 '

spawn ssh-copy-id-I $ ssh key $ user @ $ host

执行{

'是/否' { send ' yes模糊彩虹r '; exp_continue}

' *password'{send'$password模糊彩虹r'}

}

expecteof简单外壳脚本实现了主板机器#! /bin/bash

功能捕获器

trap''INTQUITTSTPTERMHUP

}

functionmenu () }

cat

==============host list=========================host list

1 ) 11.0.0.7

2 ) 10.0.0.8

3 )退出

==============hostend===========================hostend==hostend=======

}

功能主机(}

USER=test09

case'$1'in

1 )1) ) )。

ssh$USER@11.0.0.7

2 )

ssh$USER@11.0.0.8

3 )3) ) )。

退出

欧洲联盟

}

功能主

whiletrue

德奥

特拉普埃r

清除器

门菜单

read-p ' plsinputyourchoice : ' num

host$num

道恩

}

main引导脚本调用板脚本cat/etc/profile.d/jump.sh

#! /bin/bash

twdbg$UID-ne0]twdbg$USER!='zihang']模糊的彩虹

/bin/bash/server/scripts/tiao ban.sh

================在不够的地方,请多多关照====================

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。