Now we actually want the output of tar to be piped into ssh and that redirects the stdin of ssh to the stdout of tar, removing any way to pass the password into sudo from the interactive terminal. The password must be followed by a newline character. Write the prompt to the standard error and read the password from the standard input instead of using the terminal device. The little bit of extra magic here is the -S option to sudo. | ssh remote_host "sudo -S bash -c \"tar -C /var/www/ -xz echo\"" (stty -echo read passwd stty echo echo $passwd tar -cz foo.*) \ Here's a modified version of Willie Wheeler's answer that transfers the file(s) via tar but also supports passing a password to sudo on the remote host. But I've found ansible to be super useful for administering remote servers, so installing it will surely bring you other benefits beyond deploying files. P.S., I realize that saying "just install this fabulous tool" is kind of a With the concise invocation being: cd sourcedir & \Īnsible -i hostname, -b -m copy -a "src=. Here's an example that is specific and fully specified, assuming the directory on your local host containing the files to be distributed is sourcedir, and that the remote target's hostname is hostname: cd sourcedir & \
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |