Using scp to transfer files to an android device

10,702

Your scp from android to the remote server permission denied means:

  • You didn't have the password right
  • You don't have permission to read the remote file or
  • You don't have permission to write the local file

Usually the answer is the third as android differs from most unix in who can write what where.

(I know this is answered in the comments, but if you don't mark it answered more people will waste time reading it like I did!)

Share:
10,702

Related videos on Youtube

Mussé Redi
Author by

Mussé Redi

Updated on September 18, 2022

Comments

  • Mussé Redi
    Mussé Redi over 1 year

    SSHDroid lets an android device function as an ssh server. vSSH is an ssh client for android devices.

    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.

    • Jason C
      Jason C almost 10 years
      "Permission denied" where? Reading the file remotely? Authenticating? Writing the file locally? For your second attempt, did you configure the android's ssh server to run on port 2222? Are you doing this over a LAN or over the internet?
    • Mussé Redi
      Mussé Redi almost 10 years
      I get the permission denied message after being prompted for the password on the remote server. file: Permission denied. So I suppose it got denied at the remote server? On the first attempt I am reading the file remotely, while using vSSH on the android device. On the second attempt I am on the remote server and writing the file to the android device. SSHDroid does indeed default to port 2222. I am doing it over LAN. Moreover, since I can connect to the android device (using the android device itself) with vSSH via port 2222 I do not think that the port number is the problem.
    • Jason C
      Jason C almost 10 years
      What happens if you do touch file on the Android device? Or if Android doesn't have touch, something like echo abc > file?
    • Mussé Redi
      Mussé Redi almost 10 years
      I can not seem to 'touch' the file (which is on the remote server) from the android device: No such file or directory.
    • Jason C
      Jason C almost 10 years
      I mean locally. In your first example you have scp user@remote:remotefile localfile. Can you actually write to localfile? Because if you go to that directory in whatever Android console you are using, and touch localfile or echo abc > localfile gives you a permission denied error, then this tells us you do not have write permissions to that location on the Android.
    • Mussé Redi
      Mussé Redi almost 10 years
      The localfile that you are referencing can not be created in the first place. And I found out why: I did not have permission to create files at the location of the SD card. My question is now: how can I get permission to write to certain locations, like the SD card. Sudo and su do not seem to be present on the ssh server (SSHDroid). Is this perhaps a limitation of the Android OS?
    • Jason C
      Jason C almost 10 years
      You should take your new question and ask over at android.stackexchange.com. Be sure to include the version of Android you are using, as I believe there were some relevant changes in Kit Kat.
    • Mussé Redi
      Mussé Redi almost 10 years
      @JasonC here it is: android.stackexchange.com/q/77421/67501 Could you have a look?