Linux Shell Remote execution Command (command line and script mode)

Source: Internet
Author: User

Shell remote execution:

  It's often necessary to execute some shell commands remotely to other nodes, and if you ssh to each host again, it's a hassle, so you can have a centralized management approach. Describes how the two shell commands are executed remotely.

Prerequisites:

 Configure SSH password-free login

for a simple command:

If you are simply performing several commands, then:

SSH " cd/home; LS "

  Basic can complete the common use for Remote node management, a few points to note:

    1. Double quotes, must have. If you do not add double quotes, the second LS command executes locally
    2. Semicolon, separated by a semicolon between two commands
How to script:

  Some remote execution of the command content, a single command can not be completed, consider the scripting way to implement:

#!/bin/bashssh [email protected] >/dev/null2>&1 <<  /hometouch  abcdefg.txtexiteeooffechodone!

  The remote execution of the content between "<< Eeooff" to "Eeooff", the operation on the remote machine is in it, note the point:

    1. << Eeooff,ssh until the end of the Eeooff, Eeooff can be modified to other forms.
    2. Redirection is intended to not show the remote output.
    3. Before the end, add exit to exit the remote node

Related Article

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.