SSH SCP Local file to Remote in Terminal Mac Os X

前端 未结 3 1480
走了就别回头了
走了就别回头了 2021-01-29 21:55

I am attempting to copy a local file \'magento.tar.gz\' from my local machine to a remote server using SSH through a VPN. This is connecting to the Virtual Machine\'s Internal I

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-29 22:17

    Just to clarify the answer given by JScoobyCed, the scp command cannot copy files to directories that require administrative permission. However, you can use the scp command to copy to directories that belong to the remote user.

    So, to copy to a directory that requires root privileges, you must first copy that file to a directory belonging to the remote user using the scp command. Next, you must login to the remote account using ssh. Once logged in, you can then move the file to the directory of your choosing by using the sudo mv command. In short, the commands to use are as follows:

    Using scp, copy file to a directory in the remote user's account, for example the Documents directory:

    scp /path/to/your/local/file remoteUser@some_address:/home/remoteUser/Documents
    

    Next, login to the remote user's account using ssh and then move the file to a restricted directory using sudo:

    ssh remoteUser@some_address
    sudo mv /home/remoteUser/Documents/file /var/www
    

提交回复
热议问题