Search code examples
sshscp

ssh failed to copy local files to the server


I have connected to the server and I am root user,but my command failed

scp -p 10010 ~/Desktop/usb.sh root@localhost:/

Error:

ssh: connect to host localhost port 22: Connection refused


Solution

  • You'll need a capital P (-P) to specify a port, from the man page: scp (1):

    -P port

    Specifies the port to connect to on the remote host. Note that this option is written with a capital 'P', because -p is already reserved for preserving the times and modes of the file in rcp(1).


    Also, ensure you user can write to the document root (/), you can always write to your home folder: (root@localhost:/root/)


    Fixed command:

    scp -P 10010 ~/Desktop/usb.sh root@localhost:/