Use the go command to quickly ssh to a specified machine

Source: Internet
Author: User

Environment: CentOS6.4

Objective:

If you need to SSH to the required machine, you need to enter the command:

SSH [Email protected]

If you need to log on to the machine frequently, is not a bit of trouble, IP old hard to remember, if I just need to enter the following command:

Go HC

Of course, this HC is just a mapping code, which means I'm going to a machine.

In summary, provide a piece of code, quickly mapping, find the specified machine and SSH past, the code is as follows:

if[" $"==""]; Then    Echo "Not found paramter! please input paramter!"Exit-1fifunctiongo_ssh () {if[" $"==" $"]; Then        Echo "found mapping, command:ssh [email protected]$4"        SSH$3@$4Exit0    fi}go_ssh $ 1 "HC" root 10.127.133.86go_ssh "hn1" root 10.127.133.87go_ssh "hn2" root 10.127.133.88Echo "Not found mapping [$], fail! fail! fail!"Exit-1

Note: Here the Red Place is a place to pay attention, you just need to expand here, you can easily manage the mapping relationship.

Not only that, you also need to put the code in the path of the system, you need the echo $path, and then put it in any directory.

Finish.

Use the go command to quickly ssh to a specified machine

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.