I am attempting to upload a file from my local machine to my server using:
scp Users\MyName\Desktop\myzipfile.zip user@host:/path/to/whereyouwant/thefile
I have a Zip file on my desktop that I am trying to upload. My problem is I do not know what the local machine directory is when using SSH.
How can I know what it is? Meaning, how do I correctly write the path to my Zip file sitting on the desktop of my local machine?
I've tried every path I can think of.
-
2What OS are you using?Alex– Alex2016年04月08日 15:55:26 +00:00Commented Apr 8, 2016 at 15:55
2 Answers 2
There is probably some environment variable pointing to your home:
scp $HOME\Desktop\myzipfile.zip user@host:/path/to/whereyouwant/thefile
But then you will have probably problem with : in the path. You can workaround it using:
cat $HOME\Desktop\myzipfile.zip | ssh user@host cat /path/to/whereyouwant/thefile
which is basically the equivalent using pure ssh. But make sure you have set-up passwordless authentication or control master, otherwise it will fail.
-
change the \ (backslash) with / (slash) in
$HOME\Desktop\myzipfile.zipfor *nix OS.Alex– Alex2016年04月08日 15:58:36 +00:00Commented Apr 8, 2016 at 15:58 -
Yes, but from the backslashes it looks like windows question.Jakuje– Jakuje2016年04月08日 15:59:30 +00:00Commented Apr 8, 2016 at 15:59
-
Yes sorry I am using Windowscpcdev– cpcdev2016年04月08日 16:10:47 +00:00Commented Apr 8, 2016 at 16:10
-
Have you tried
scp \Users\MyName\Desktop\myzipfile.zip\ user@host:/path/to/whereyouwant/thefile?Alex– Alex2016年04月08日 17:17:40 +00:00Commented Apr 8, 2016 at 17:17
Instead of specifying "Users", which indicates the sub-directory named "Users" underneath whatever the local directory is, specify "\Users", which indicates a directory named "Users" off of the root directory of the current drive.
Or maybe even try "C:\Users" at the start.
Or simply use CD to the desired directory (e.g. "CD \Users\MyName\Desktop") and then use SCP on the "myzipfile.zip" file without specifying a path.
Also, note that on the remote end, after the colon, you don't need to start with a slash. You could start with a period, and then a slash. By doing so, you will write to the "current directory" after logging in, which will usually be whatever directory is called the "home directory" for whatever user account you use.