Meow, I wrote an article by a microphone, and I got my fingers again. The article is a battle report for the lazy man in macos.
Meow, I wrote an article by a microphone, and I got my fingers again. The article is a battle report for the lazy man in macos.
Sshpass:
In linux, you can directly use command lines to connect to an ssh server with a password.
Format:
sshpass -p password ssh root@hostloc
:
Http://sourceforge.net/projects/sshpass? Source = navbar
Shell management server script
#!/bin/bashfunction checkim(){ user=`whoami` if [ "$user" != "root" ]; then read -p "You Password: " rootpass sudo su - echo $rootpass fi}function alert(){ echo -e "$1"}function add(){ echo "add a server to your local conf" read -p "server name: " sname read -p "server user: " suer read -p "server host: " shost read -p "server pass: " spass echo $sname $suer $shost $spass >> host.cf}function del(){ echo -e "del server"}function goto(){ list read -p "input server name:" h a=`grep $h host.cf | awk '{print $2}'` b=`grep $h host.cf | awk '{print $3}'` c=`grep $h host.cf | awk '{print $4}'` if [ ! -n $c] ;then sshpass -p $c ssh $a@$b else ssh $a@$b fi exit 0}function list(){ alert "" echo "your owner server list"; awk -F ' ' '{print $1,$2}' host.cf alert ""}function main(){ echo -e "please choose your command for service\n\r" echo -e "1.server list" echo -e "2.server add" echo -e "3.server del" echo -e "4.server goto" echo -e "5.close this shell"}function version(){ echo -e "author : 80aj url: http://www.80aj.com" echo -e "for cmommand manage linux server"}clearversionalert " "#checkimwhile :domainread -p "choose your service:" cmdcase "$cmd" in1) list;;2) add;;3) del;;4) goto;;5) echo "Bye !";exit 0;;*) echo "input error"esacdoneexit 0
Goodjob bye ~