solichris.blogg.se

Copy file from local to ssh
Copy file from local to ssh







  1. #COPY FILE FROM LOCAL TO SSH INSTALL#
  2. #COPY FILE FROM LOCAL TO SSH PASSWORD#

(stty -echo read passwd stty echo echo $passwd tar -cz foo.*) \

#COPY FILE FROM LOCAL TO SSH PASSWORD#

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.

#COPY FILE FROM LOCAL TO SSH INSTALL#

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 & \

  • Copying a directory is supported by the copy module, but not by the fetch module.
  • Using wildcards in the file paths isn't supported by these ansible modules.
  • flat=yes copies just the file, doesn't copy whole remote path leading to the file.
  • b expands to -become, and the default -become-user is root, with the default -become-method being sudo.

    copy file from local to ssh

    -b causes the actions on the server to be done as root.It is the way to use ansible without needing an inventory file. The comma in the -i HOST, syntax is not a typo.Copy to remote host using ansible's copy module: ansible -i HOST, -b -m copy -a "src=SRC_FILEPATH dest=DEST_FILEPATH" allįetch from remote host using ansible's fetch module: ansible -i HOST, -b -m fetch -a "src=SRC_FILEPATH dest=DEST_FILEPATH flat=yes" all You can also use ansible to accomplish this.

    copy file from local to ssh

    Technically, you can configure Ubuntu to allow remote login directly as root, but this feature is disabled for a reason, so I would strongly advice you against doing that. Generally, working in the root account should be an exception, not a rule - the way you phrasing your question makes me think maybe you're abusing it a bit, which in turn leads to problems with permissions - under normal circumstances you don't need super-admin privileges to access your own files. scp -r folder/ sudo mv /some/folder /some/folder/requiring/permsĪnother solution would be to change permissions/ownership of the directories you uploading the files to, so your non-privileged user is able to write to those directories. A workaround is to use scp to upload files to a directory where your user has permissions to create files, then log in via ssh and use sudo to move/copy files to their final destination. You're right, there is no sudo when working with scp.









    Copy file from local to ssh