I need to transfer files from my windows based server to my Linux server using SFTP protocol. They are in the same LAN network.
I have enabled SFTP on my Linux server.
Using:
sudo apt-get install openssh-server
sudo apt-get install ssh
I made a group (I call it sftponly) and a user (abc) for my SFTP server.
I am using PuTTY as my SSH client in Windows environment.
In my Windows, I have a text file located in c:/myfile/myfile.txt
and I want to upload this file using SFTP into my Linux server
My batch file code looks like:
start putty.exe -ssh 192.168.0.117:4747 -l admin-pw Password -m C:\\test\ssh.txt
The contents of my ssh.txt
is:
sftp abc@192.168.0.117
put c:/myfile/myfile.txt
I am sure the put
syntax is wrong because we are in Windows environment. What is the missing code in my ssh.txt
file so I can upload the myfile.txt
into SFTP?
The abc user has all the privileges.
The remote sftp
process cannot access the local files on your Windows machine.
(Even if it could, your script file is still wrong, as the the put
will be executed [and not understood] by a shell, not by the sftp
.)
You have to use a local SFTP client to upload the files to the remove SFTP server.
The PuTTY comes with the psftp.exe
SFTP client that mimics the OpenSSH sftp
client.
psftp.exe abc@192.168.0.117 -b C:\test\ssh.txt
Where the ssh.txt
contains the put
command:
put c:\myfile\myfile.txt