-2

this is how to shh to server

ssh -p 2222 thatilike@192.185.21.105

I want to copy file logo.png to public_html folder on server

This is what I tried

scp ./logo.png -p 2222 thatilike@192.185.21.105:/public_html/

Don't know why not work

alexus
  • 13,112
  • 32
  • 117
  • 174
angry kiwi
  • 109
  • 1
  • 1
  • 3

2 Answers2

5

per man scp

 -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).

 -p      Preserves modification times, access times, and modes from the original file.

corrected syntax:

scp -P 2222 ./logo.png thatilike@192.185.21.105:/public_html/

example:

$ touch ./logo.png
$ scp -P XXXXX ./logo.png XXX@XXX.XXX:/tmp/
logo.png                                                             100%    0     0.0KB/s   00:00    
$ 

to check connectivity (via ssh) and target directory exist do following.

$ ssh -p XXXXX XXX@XXX.XXX 'if [ -d /tmp/ ] ; then ls -ld /tmp/ ; fi'
drwxrwxrwt  21 root  wheel  31232 Mar  3 23:04 /tmp/
$ 
alexus
  • 13,112
  • 32
  • 117
  • 174
3

Your command line doesn't specify the port number correctly.

As seen in the scp man page:

     -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.
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972