Using scp to transfer files to an android device

9,745

Physically go to the remote_host and change the file owner to remote_user.

sudo chown remote_user /path/to/file

Then you should have permissions to copy the file.

Share:
9,745

Related videos on Youtube

Mussé Redi
Author by

Mussé Redi

Updated on September 18, 2022

Comments

  • Mussé Redi
    Mussé Redi over 1 year

    I have a file on a remote server that I want to transfer to my android device over ssh, only using the android device in the process.

    Using this setup, I tried an scp from the android device

    scp remote_user@remote_host:file file
    

    After being prompted for the password I got permission denied.

    I then tried to transfer it from the remote server

    scp -P 2222 file root@SSHDroid-ip:/mnt/extSdCard/file
    

    Without being prompted for the password I now get the message that the network (of the android device) is unreachable: lost connection.

    Is this a permission problem? I have transferred files over ssh from the remote server before, so I suppose the problem is on the side of the android device.

    Edit.

    I can transfer the file, from the remote server to the android device via scp, to the home path of the SSHDroid server on the android device. This home path is very cumbersome and deep, and can not be reached with the regular android API of the device.

    So I can transfer it to the home path of the SSHDroid server, but not to the path of my SD card on the android device. Where can I change/check the permission settings of the android device?

    • beginer
      beginer almost 10 years
      Are you sure remote_user has premission to file on the remote_host ? Similarly are you running an ssh server in your android on port 2222 ?
    • Mussé Redi
      Mussé Redi almost 10 years
      I can edit the file on remote_user, so I suppose I have permission to access it. remote_host is the university server. I am indeed running an ssh server (SSHDroid) on my android device which defaults to port 2222. Since I can connect to it using vSSH, the port number should not be the issue.
    • beginer
      beginer almost 10 years
      Time to debug. You can verbose your scp and check. Man page shows you can use -vvv for maximum verbose.
  • Rucent88
    Rucent88 almost 10 years
    Login into the remote computer with ssh. If you do not have permission to read the file while logged in with ssh, then you will not be able to copy it with scp.
  • Rucent88
    Rucent88 almost 10 years
    Then I think you should check that you have permission to create files in the local directory (android side). Also, double check that the file names and directory locations are exactly correct, both locally and remotely.
  • Mussé Redi
    Mussé Redi almost 10 years
    I verified that I had no permission creating a file on the SD card by trying to save a text file with vi. How can I change/get root privileges on the android device, that is, at the location of the SD card? Sudo and su does not seem to be present on the android ssh server.
  • Rucent88
    Rucent88 almost 10 years
    @MusséRedi I answered the question you posted about scp. Now you're asking a new question about how to edit permissions on android. I do not know the answer to your new question. You will need to make a new Question post. Android StackExchange can probably help you. :)
  • Mussé Redi
    Mussé Redi almost 10 years
  • Mussé Redi
    Mussé Redi almost 10 years
    It turned out that in Android 4.4 Google removed the permission to write to the external SD card. So it is a limitation of the Android OS. This can only be circumvented by rooting the device, which I am not going to do. I will just write to the internal SD card as an alternative. And by the way, sudo and su are not present on the ssh server that I am using (SSHDroid).