Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Dradden

I got this working, thanks for the help :) Leaving it here maybe will help somebody out.
cd C:\Program Files (x86)\WinSCP
winscp.com /command ^
   "open sftp://root@removed/ -hostkey=""ssh-ed25519 256 removed="" -privatekey=""D:\Cryp\server\Private Keys\server.ppk""" ^
   "synchronize local D:\server_backups /root/winscp_sync" ^
   "exit"
Dradden

Edit: I have fixed the below it was as you had said quotes. Now WinSCP opens and stalls at winscp>. It isn't executing the synchronize local command for some reason.

I have tried that and get the same result:
"open sftp://root@removed/ -hostkey="ssh-ed25519 256 removed=" -privatekey="D:\Cryp\server\Private Keys\server.ppk"""

That part works ok, the actual directories I have an issue with it seems. Have tried a few different variations.
"synchronize local D:\server_backups /root/winscp_sync"

"synchronize local "D:\server_backups" "/root/winscp_sync"""

Always get back the same:
C:\Program Files (x86)\WinSCP>winscp.com /command "open sftp://root@removed/ -hostkey="ssh-ed25519 256 removed=" -privatekey="D:\Cryp\server\Private Keys\server.ppk"""

Searching for host...
Connecting to host...
Authenticating...
Using username "root".
Authenticating with public key "server" from agent.
Authenticated.
Starting the session...
Session started.
Active session: [1] root@removed
Unknown command '256'.

C:\Program Files (x86)\WinSCP>"synchronize local D:\server_backups /root/winscp_sync"
The filename, directory name, or volume label syntax is incorrect.
Dradden

Have not been able to figure this out, pretty strange.
Dradden

Thanks, that helped some. Connection is now working, but it complains about unknown command and path. I am not sure why. Here is the output:
C:\Program Files (x86)\WinSCP>winscp.com /command "open sftp://root@removed/ -hostkey="removed=" -privatekey="D:\Cryp\server\Private Keys\server.ppk"" ^

Searching for host...
Connecting to host...
Authenticating...
Using username "root".
Authenticating with public key "server" from agent.
Authenticated.
Starting the session...
Session started.
Active session: [1] root@removed
Unknown command '256'.

C:\Program Files (x86)\WinSCP>"synchronize local D:\server backups /root/winscp_sync"
The filename, directory name, or volume label syntax is incorrect.

The directories are correct, triple checked. Not sure if related to the "Unknown command '256'."

New .bat contents:
cd C:\Program Files (x86)\WinSCP
winscp.com /command ^
"open sftp://root@removed/ -hostkey="removed=" -privatekey="D:\Cryp\server\Private Keys\server.ppk"" ^
"synchronize local D:\server backups /root/winscp_sync"

Do you see why it is failing?
Dradden

"open" not completely logging in

Trying to get this set so WinSCP will keep the local (Windows) folder synchronized with the remote (Linux) machine folder.

Script:
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.exe"
open sftp://root@ipremoved/ -hostkey="hostkey_removed=" -privatekey="D:\Cryp\server\Private Keys\server_key.ppk"
"synchronize local D:\server backups /root/winscp_sync"
"exit"
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)
exit /b %WINSCP_RESULT

This opens WinSCP program itself but stops there. What am I missing? Pageant is running and logging in normally with the program is fine.