Search code examples
linuxbashsshfile-transferscp

Transferring file using SCP command fails with relative path and works with absolute path


This is failing. (the file.txt is in the same folder)

sudo scp file.txt shahid@11.34.45.23:~/
#gives error Permission denied (publickey).

The following works, however, it asks for the local machine password

sudo scp me@localhost:/home/file.xt shahid@11.34.45.23:~/

Solution

  • If the file.txt doesn't contain any critical data, change its permissions to allow reading by others:

    $ sudo chmod 744 file.txt
    

    And then try the scp.