Using scp to transfer files to an android device
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.
Related videos on Youtube
Mussé Redi
Updated on September 18, 2022Comments
-
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 devicescp 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 almost 10 yearsAre you sure
remote_user
has premission tofile
on theremote_host
? Similarly are you running an ssh server in your android on port2222
? -
Mussé Redi almost 10 yearsI 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 almost 10 yearsTime to debug. You can verbose your scp and check. Man page shows you can use
-vvv
for maximum verbose.
-
-
Rucent88 almost 10 yearsLogin into the remote computer with
ssh
. If you do not have permission to read the file while logged in withssh
, then you will not be able to copy it withscp
. -
Rucent88 almost 10 yearsThen 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 almost 10 yearsI 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 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 almost 10 yearsI did, earlier today android.stackexchange.com/q/77421/67501
-
Mussé Redi almost 10 yearsIt 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).