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

martin

Re: Problem with windows scheduled tasks

I do not understand the first part of your question.

Regarding the passphrase: WinSCP currently does not support specifying a passphrase for the tunnel. You have to use a private key without a passphrase.
ChloeShepard

Problem with windows scheduled tasks

Hello, I'm having two issues right now.

Issue one is that I can't run a script that uses no passphrase for the SSH key that works when used directly on CMD on the task scheduler. The script for this log is:
open sftp://root@192.168.0.1/ -hostkey="ssh-ed25519 255 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=" -privatekey="C:\Users\Username\AppData\Local\Programs\WinSCP\Keys\prkeyRoot.ppk" -rawsettings FSProtocol=2 Shell="/bin/bash" Tunnel=1 TunnelHostName="192.168.0.1" TunnelUserName="root" TunnelPublicKeyFile="C:%5CUsers%5CUsername%5CAppData%5CLocal%5CPrograms%5CWinSCP%5CKeys%5CprkeyRoot.ppk" TunnelPasswordPlain=""
 
lcd "C:\Users\Username\Directory"
cd "/Directory"
 
synchronize remote -criteria=either -nopermissions -transfer=automatic -preservetime=all -rawtransfersettings[1] "Directory"
 
exit


The log of this problem is this one.
. 2021-02-24 17:37:08.218 Log level: Normal
. 2021-02-24 17:37:08.218 Local account: PcName\Username
. 2021-02-24 17:37:08.218 Working directory: C:\WINDOWS\system32
. 2021-02-24 17:37:08.218 Process ID: 24556
. 2021-02-24 17:37:08.218 Command-line: C:\Users\Username\AppData\Local\Programs\WinSCP\WinSCP.exe /ini=nul /script="C:\Users\Username\AppData\Local\Programs\WinSCP\Scripts\ActualizarArchivosServer\synchronize.txt" /Log="C:\Users\Username\AppData\Local\Programs\WinSCP\Scripts\ActualizarArchivosServer\logcmd4.log"
. 2021-02-24 17:37:08.218 Time zone: Current: GMT+1, Standard: GMT+1 (Hora estándar Europa Occidental), DST: GMT+2 (Hora de ver. Europa Occidental), DST Start: 28/03/2021, DST End: 31/10/2021
. 2021-02-24 17:37:08.218 Login time: miércoles, 24 de febrero de 2021 17:37:08
. 2021-02-24 17:37:08.218 --------------------------------------------------------------------------
. 2021-02-24 17:37:08.218 Script: Retrospectively logging previous script records:
> 2021-02-24 17:37:08.218 Script: open sftp://root@192.168.0.1/ -hostkey="ssh-ed25519 255 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=" -privatekey="C:\Users\Username\AppData\Local\Programs\WinSCP\Keys\prkeyRoot.ppk" -rawsettings FSProtocol=2 Shell="/bin/bash" Tunnel=1 TunnelHostName="192.168.0.1" TunnelUserName="root" TunnelPublicKeyFile="C:%5CUsers%5CUsername%5CAppData%5CLocal%5CPrograms%5CWinSCP%5CKeys%5CprkeyRoot.ppk"
. 2021-02-24 17:37:08.218 --------------------------------------------------------------------------
. 2021-02-24 17:37:08.218 Session name: root@192.168.0.1 (Ad-Hoc site)
. 2021-02-24 17:37:08.218 Host name: 192.168.0.1 (Port: 22)
. 2021-02-24 17:37:08.218 User name: root (Password: No, Key file: Yes, Passphrase: No)
. 2021-02-24 17:37:08.218 Tunnel: Yes
. 2021-02-24 17:37:08.218 Tunnel: Host name: 192.168.0.1 (Port: 22)
. 2021-02-24 17:37:08.218 Tunnel: User name: root (Password: Yes, Key file: Yes)
. 2021-02-24 17:37:08.218 Tunnel: Local port number: 0
. 2021-02-24 17:37:08.218 Transfer Protocol: SFTP
. 2021-02-24 17:37:08.218 Ping type: Off, Ping interval: 30 sec; Timeout: 15 sec
. 2021-02-24 17:37:08.218 Disable Nagle: No
. 2021-02-24 17:37:08.218 Proxy: None
. 2021-02-24 17:37:08.218 Send buffer: 262144
. 2021-02-24 17:37:08.218 SSH protocol version: 2; Compression: No
. 2021-02-24 17:37:08.218 Bypass authentication: No
. 2021-02-24 17:37:08.218 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: Yes
. 2021-02-24 17:37:08.218 GSSAPI: Forwarding: No; Libs: gssapi32,sspi,custom; Custom:
. 2021-02-24 17:37:08.218 Ciphers: aes,chacha20,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2021-02-24 17:37:08.218 KEX: ecdh,dh-gex-sha1,dh-group14-sha1,rsa,WARN,dh-group1-sha1
. 2021-02-24 17:37:08.218 SSH Bugs: Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto
. 2021-02-24 17:37:08.218 Simple channel: Yes
. 2021-02-24 17:37:08.218 Return code variable: Autodetect; Lookup user groups: Auto
. 2021-02-24 17:37:08.218 Shell: /bin/bash
. 2021-02-24 17:37:08.218 EOL: LF, UTF: Auto
. 2021-02-24 17:37:08.218 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes; Follow directory symlinks: No
. 2021-02-24 17:37:08.218 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No; Exit code 1 is error: No
. 2021-02-24 17:37:08.218 SFTP Bugs: Auto,Auto
. 2021-02-24 17:37:08.218 SFTP Server: default
. 2021-02-24 17:37:08.218 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2021-02-24 17:37:08.218 Cache directory changes: Yes, Permanent: Yes
. 2021-02-24 17:37:08.218 Recycle bin: Delete to: No, Overwritten to: No, Bin path:
. 2021-02-24 17:37:08.218 DST mode: Unix
. 2021-02-24 17:37:08.218 --------------------------------------------------------------------------
. 2021-02-24 17:37:08.218 Opening tunnel.
. 2021-02-24 17:37:08.218 Autoselected tunnel local port number 50001
. 2021-02-24 17:37:08.218 [Tunnel] Looking up host "192.168.0.1" for SSH connection
. 2021-02-24 17:37:08.218 [Tunnel] Connecting to 192.168.0.1 port 22
. 2021-02-24 17:37:08.249 [Tunnel] We claim version: SSH-2.0-WinSCP_release_5.17.10
. 2021-02-24 17:37:08.302 [Tunnel] Remote version: SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
. 2021-02-24 17:37:08.302 [Tunnel] Using SSH protocol version 2
. 2021-02-24 17:37:08.338 [Tunnel] Doing ECDH key exchange with curve Curve25519 and hash SHA-256
. 2021-02-24 17:37:08.450 [Tunnel] Server also has ecdsa-sha2-nistp256/ssh-rsa host keys, but we don't know any of them
. 2021-02-24 17:37:08.450 [Tunnel] Host key fingerprint is:
. 2021-02-24 17:37:08.450 [Tunnel] ssh-ed25519 255 XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=
. 2021-02-24 17:37:08.450 [Tunnel] Closing connection.


For some reason the same script I have used that resulted in this log works perfectly when executed directly on CMD.

Now my second issue is trying to execute this script but using a passphrase for the SSH key. This script doesn't work on task scheduler nor on CMD. The script for this is as it follows.
open sftp://root@192.168.0.1/ -hostkey="ssh-ed25519 255 XXXXXXXXXXXXXXXXXXXXXXXXXXXXX=" -privatekey="C:\Users\Username\AppData\Local\Programs\WinSCP\Keys\prkeyChloe.ppk" -passphrase="Password" -rawsettings AgentFwd=1 FSProtocol=2 Tunnel=1 TunnelHostName="192.168.0.1" TunnelUserName="root" TunnelPublicKeyFile="C:%5CUsers%5CUsername%5CAppData%5CLocal%5CPrograms%5CWinSCP%5CKeys%5CprkeyChloe.ppk"
 
lcd "C:\Users\Username\Directory"
cd /Directory
 
synchronize remote -criteria=either -nopermissions -transfer=automatic -preservetime=all -rawtransfersettings[1] "Directory"
 
exit


The log result is:
. 2021-02-24 17:09:45.533 Tunnel: Host name: 192.168.0.1 (Port: 22)
. 2021-02-24 17:09:45.533 Tunnel: User name: root (Password: No, Key file: Yes)
. 2021-02-24 17:09:45.533 Tunnel: Local port number: 0
. 2021-02-24 17:09:45.533 Transfer Protocol: SFTP
. 2021-02-24 17:09:45.533 Ping type: Off, Ping interval: 30 sec; Timeout: 15 sec
. 2021-02-24 17:09:45.533 Disable Nagle: No
. 2021-02-24 17:09:45.533 Proxy: None
. 2021-02-24 17:09:45.533 Send buffer: 262144
. 2021-02-24 17:09:45.533 SSH protocol version: 2; Compression: No
. 2021-02-24 17:09:45.533 Bypass authentication: No
. 2021-02-24 17:09:45.533 Try agent: Yes; Agent forwarding: Yes; TIS/CryptoCard: No; KI: Yes; GSSAPI: Yes
. 2021-02-24 17:09:45.533 GSSAPI: Forwarding: No; Libs: gssapi32,sspi,custom; Custom:
. 2021-02-24 17:09:45.533 Ciphers: aes,chacha20,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2021-02-24 17:09:45.533 KEX: ecdh,dh-gex-sha1,dh-group14-sha1,rsa,WARN,dh-group1-sha1
. 2021-02-24 17:09:45.533 SSH Bugs: Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto
. 2021-02-24 17:09:45.533 Simple channel: Yes
. 2021-02-24 17:09:45.533 Return code variable: Autodetect; Lookup user groups: Auto
. 2021-02-24 17:09:45.533 Shell: default
. 2021-02-24 17:09:45.533 EOL: LF, UTF: Auto
. 2021-02-24 17:09:45.533 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes; Follow directory symlinks: No
. 2021-02-24 17:09:45.533 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No; Exit code 1 is error: No
. 2021-02-24 17:09:45.533 SFTP Bugs: Auto,Auto
. 2021-02-24 17:09:45.548 SFTP Server: default
. 2021-02-24 17:09:45.548 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2021-02-24 17:09:45.548 Cache directory changes: Yes, Permanent: Yes
. 2021-02-24 17:09:45.548 Recycle bin: Delete to: No, Overwritten to: No, Bin path:
. 2021-02-24 17:09:45.548 DST mode: Unix
. 2021-02-24 17:09:45.548 --------------------------------------------------------------------------
. 2021-02-24 17:09:45.548 Opening tunnel.
. 2021-02-24 17:09:45.548 Autoselected tunnel local port number 50001
. 2021-02-24 17:09:45.548 [Tunnel] Looking up host "192.168.0.1" for SSH connection
. 2021-02-24 17:09:45.548 [Tunnel] Connecting to 192.168.0.1 port 22
. 2021-02-24 17:09:45.580 [Tunnel] We claim version: SSH-2.0-WinSCP_release_5.17.10
. 2021-02-24 17:09:45.627 [Tunnel] Remote version: SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
. 2021-02-24 17:09:45.627 [Tunnel] Using SSH protocol version 2
. 2021-02-24 17:09:45.627 [Tunnel] Have a known host key of type ssh-ed25519
. 2021-02-24 17:09:45.664 [Tunnel] Doing ECDH key exchange with curve Curve25519 and hash SHA-256
. 2021-02-24 17:09:45.780 [Tunnel] Server also has ecdsa-sha2-nistp256/ssh-rsa host keys, but we don't know any of them
. 2021-02-24 17:09:45.780 [Tunnel] Host key fingerprint is:
. 2021-02-24 17:09:45.780 [Tunnel] ssh-ed25519 255 XX:XX:XX:XX:XX:XX:XX:XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=
. 2021-02-24 17:09:45.780 [Tunnel] Host key matches cached key
. 2021-02-24 17:09:45.780 [Tunnel] Initialised AES-256 SDCTR (AES-NI accelerated) outbound encryption
. 2021-02-24 17:09:45.780 [Tunnel] Initialised HMAC-SHA-256 outbound MAC algorithm
. 2021-02-24 17:09:45.780 [Tunnel] Initialised AES-256 SDCTR (AES-NI accelerated) inbound encryption
. 2021-02-24 17:09:45.780 [Tunnel] Initialised HMAC-SHA-256 inbound MAC algorithm
. 2021-02-24 17:09:45.811 [Tunnel] Reading key file "C:\Users\Username\AppData\Local\Programs\WinSCP\Keys\prkeyChloe.ppk"
! 2021-02-24 17:09:45.811 [Tunnel] Using username "root".
. 2021-02-24 17:09:45.860 [Tunnel] Server offered these authentication methods: publickey
. 2021-02-24 17:09:45.860 [Tunnel] Offered public key
. 2021-02-24 17:09:45.895 [Tunnel] Offer of public key accepted
! 2021-02-24 17:09:45.895 [Tunnel] Authenticating with public key "rsa-key-00000000"
. 2021-02-24 17:09:45.895 [Tunnel] Prompt (passphrase, "SSH key passphrase", <no instructions>, "Passphrase for key "rsa-key-00000000": ")
. 2021-02-24 17:09:45.895 [Tunnel] User aborted at passphrase prompt
. 2021-02-24 17:09:45.896 [Tunnel] Closing connection.


I would like to know how to, if possible, use the script with the passphrase on the Task Scheduler without asking for a prompt that will stop the script. Even if I have already used -passphrase.