I need to copy file somefile.jar
from local computer (cygwin) to remote server.local
. I have an ssh login corp
to server.local
that a sudoer on server.local
. I need to place the file to folder /opt/alice/libs/
owned by another user:
[[email protected] ~]$ ls -ld /opt/alice/libs
drwxr-xr-x 2 alice alice 12288 Apr 13 11:09 /opt/alice/libs
I cannot direct upload file to chosen directory because of insufficient rights. So, my way to copy has few steps with /tmp/
on server.local
$ scp ./somefile.jar [email protected]/tmp/
$ ssh [email protected]
Last login: Thu Apr 12 18:05:41 2018 from 192.168.87.34
[[email protected] ~]$ sudo chown alice:alice /tmp/somefile.jar
[[email protected] ~]$ sudo -u alice mv /tmp/somefile.jar /opt/alice/libs/
Is there a shorter way to perform the upload?
If a tool does not exist to achieve my purposes, maybe it is possible to make a *.sh
script that include all of these operations?
alice
user