SCP copy windows local file to linux remote folder
Umm, if you're using cygwin you want that command to look like
scp /cygdrive/d/test.txt <linux ip>:/etc/var/test/test.txt
Or you can use WinSCP, you'll probably find that simpler.
The best way to copy files from Windows to Linux using the command line is through pscp. It is very easy and secure. For pscp to work on your windows machine, you need it add its executable to your systems path. Once it is done, you can use the following format to copy the file.
pscp -pw password D:\test.txt [email protected]:/etc/var/test/test.txt
You can refer the following blog post for more information on pscp setup.
http://comtechies.com/2016/02/copy-files-between-windows-and-linux.html
Assuming you are on Windows, best way is to download and install cygwin. Get the path to the binary folder and add it to the system path. You can now run Linux commands on your command line.
Open the command prompt and go to the directory where your file is that you want to copy. Run the following command;
scp file.txt [email protected]:/opt/
- scp - secure copy command
- file.txt - file you want to copy
- root - username used to log onto CentOS machine
- 1.1.1.1 - IP address of CentOS machine. Needless to say your Windows machine and the CentOS machine have to be able to communicate with one another
- :/opt - This is the directory with which you save the file to, I generally save everything to the /opt directory
- Don't forget the @ between the username and IP Address and the : between the IP Address and directory you are saving the file to
If you need a key to login into the server, enter the following;
scp key.pem file.txt [email protected]:/opt
For handiness sake I just copy the file I want to copy across to the key file directory, that way you know everything will run smoothly
I would highly recommend to use WinSCP if you're a Windows user. It has a good intuitive interface and gets the job done easily and with no pain.
Download link
to copy a file from windows to linux write:
scp -i privatekey pathFileOnWindows user@publicIp:pathDirectoryLinux
(the colon : is important!)
Example:
//I am located here in my console
C:\Users\oscar>
//I'm executing the next command
scp -i C:\Users\oscar\Documents\llaves\ubuntu.pem C:\Users\oscar\Documents\index.html [email protected]:~/
You can puth the full path or location in the path where the file is located. ~/
means the home directory of the user ubuntu