Macosshell manages ssh servers

Source: Internet
Author: User
Tags ssh server
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 ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.