admin管理员组

文章数量:1572326

refs:

http://stackoverflow/questions/5162568/linux-execute-command-remotely

http://serverfault/questions/241588/how-to-automate-ssh-login-with-password

http://stackoverflow/questions/12202587/automatically-enter-ssh-password-with-script

http://stackoverflow/questions/19996089/use-ssh-to-start-a-background-process-on-a-remote-server-and-exit-session



ssh -OPTIONS -p SSH_PORT user@remote_server "remote_command1; remote_command2; remote_script.sh"  



 ssh user@machine 'bash -s' < local_script.sh

or you can just

 ssh user@machine "remote command to run" 



ssh自动输入密码

First you need to install sshpass.

Ubuntu/Debian: apt-get install sshpass
Fedora/CentOS: yum install sshpass
Arch: pacman -S sshpass

SSHPASS EXAMPLE:

sshpass -p "YOUR_PASSWORD" ssh -o StrictHostKeyChecking=no YOUR_USERNAME@SOME_SITE.COM

SSHPASS CUSTOM PORT EXAMPLE:

sshpass -p "YOUR_PASSWORD" ssh -o StrictHostKeyChecking=no YOUR_USERNAME@SOME_SITE.COM:2400


ssh 执行远程指令后不会立刻返回,可用 -f 来实现。



The "-f" option to ssh tells ssh to run the remote command in the background and to return immediately. E.g.,

ssh -f user@host "echo foo; sleep 5; echo bar"

If you type the above, you will get your shell prompt back immediately, you will then see "foo" output. Five seconds later you will then see "bar" output. In the meantime, you could have been using the shell.

无效?



本文标签: RemoteDeployExecutive