SCP w/ ssh: copying a local file from windows to a

2019-01-30 17:42发布

问题:

So, I'm attempting to simply transfer folder of files from my local computer to a server via ssh and scp. After sudoing I'm using the command as follows:

scp -r C:/desktop/myfolder/deployments/ user@host:/path/to/whereyouwant/thefile

I get the error:

ssh: C: Name or service not known

I'm guessing its my syntax for c:/desktop etc. Any ideas?

BTW I'm using putty + Windows 7.

回答1:

If your drive letter is C, you should be able to use

scp -r \desktop\myfolder\deployments\ user@host:/path/to/whereyouwant/thefile

without drive letter and backslashes instead of forward slashes.

You are using putty, so you can use pscp. It is better adapted to Windows.



回答2:

Drive letters can be used in the target like

scp some_file user@host:/c/temp

where c is the drive letter. It's treated like a directory.

Maybe this works on the source, too.



回答3:

On windows you can use a graphic interface of scp using winSCP. A nice free software that implements SFTP protocol.



回答4:

You can also try this:

scp -r /cygdrive/c/desktop/myfolder/deployments/ user@host:/path/to/whereyouwant/thefile


回答5:

I have found it easiest to use a graphical interface on windows (I recommend mobaXTerm it has ssh, scp, ftp, remote desktop, and many more) but if you are set on command line I would recommend cd'ing into the directory with the source folder then
scp -r yourFolder username@server:/path/to/dir
the -r indicates recursive to be used on directories



回答6:

Drive letter can be used in the source like

scp /c/path/to/file.txt user@server:/dir1/file.txt