Linux Shell Remote Interactive command

Source: Internet
Author: User

SCP implementation data copy other machine copy to local file: SCP [email protected]/ip:filepath localpath Local copy to other machine: SCP localpath [email PROTECTED]/IP: FilePath folder copy:scp-r [email protected]/ip:folderpath localpath Detailed reference: http://blog.csdn.net/xifeijian/article/ details/9364497
If the remote machine encryption or use security mechanism, we may run this command will need to enter the password, in order to make automation, you can
#在脚本所在服务器上操作
SSH-KEYGEN-T RSA
You can use the default value and then upload the resulting public key to the target machine.
SCP ~/.ssh/id_rsa.pub [email protected] remote machine Ip:/userhome/.ssh/authorized_keys
http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=111248
Scp-i ${key}-o Gssapiauthentication=no (-R) SourcePath [email protected]:d Estpath}

Shell Remote Execution commandYou must configure SSH password-free login.

If you are simply performing several commands, then:

SSH " CMD1;CMD2 "
SSH [email protected] ' ls ~/mnt/builds|grep 2.5 '

Note :

1. If you want to execute commands on a remote machine, you must have single or double quotation marks behind SSH. If you do not add double quotes, the second command executes locally

2. Separate the two commands with a semicolon

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/NULL 2>&1<<EEOOFFCD/HomeTouchAbcdefg.txtexiteeooffEcho  Done!

remote execution of 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
Reference: http://blog.csdn.net/xifeijian/article/details/9364497

Linux Shell Remote Interactive command

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.