您的位置:首页 > 其它

remote deploy or remote executive

2016-01-21 15:35 309 查看
refs:
http://stackoverflow.com/questions/5162568/linux-execute-command-remotely http://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password http://stackoverflow.com/questions/12202587/automatically-enter-ssh-password-with-script http://stackoverflow.com/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.


无效?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: