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:
- << Eeooff,ssh until the end of the Eeooff, Eeooff can be modified to other forms.
- Redirection is intended to not show the remote output.
- Before the end, add exit to exit the remote node
Reference: http://blog.csdn.net/xifeijian/article/details/9364497
Linux Shell Remote Interactive command