Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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: password

@dev: Everything is explained in the posts above or in the links.
If you want to include your password to session URL, the encoding is:
n%25%28DZFe6eB%2Fkt%5D%245%7E%3CU_
(I've used the GUI to generate the encoded password [again as described in the links] – some of the special characters might not really need encoding, the GUI is too strict in this respect when generating the code)
Or you can use -password switch to avoid need to encoding the password.
And if you want to use it in a batch file, you have to double the percent signs.
dev

password

How about if the password is n%(DZFe6eB/kt]$5~<U_
asholino

login

So for example if my password is MNOPUJHHsdks+lskiwiij in a script I just put ftp://user:MNOPUJHHsdks%2Blskiwiij or MNOPUJHHsdks%%2Blskiwiij
pswong

Re: password with special character

Thank you very much!
pswong

password with special character

Hi,
I have changed my special character as according to the guide, which as the following,
"C:\Program Files (x86)\WinSCP\winscp.com"  sftp://root:Nh212%23%24%25@10.1.16.248/ -hostkey="ssh-ed25519 256 9SS0Zzzl1Qyj30dK0k50tu47cnVgD2C1tn6y/x0Ns7A="

This work all right, if I paste this in the CMD directly.
But when I saved as batch file, the password is somehow encoded to Nh212345

Generated Log:
. 2018-06-15 20:44:42.397 WinSCP Version 5.13.2 (Build 8455) (OS 6.3.9600 - Windows Server 2012 R2 Datacenter)
. 2018-06-15 20:44:42.397 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\
. 2018-06-15 20:44:42.397 Log level: Debug 2, Logging passwords
. 2018-06-15 20:44:42.397 Local account: PMBIPMSTI17\Administrator
. 2018-06-15 20:44:42.397 Working directory: C:\Users\Administrator\Desktop
. 2018-06-15 20:44:42.397 Process ID: 1808
. 2018-06-15 20:44:42.397 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console=5.13.2 /consoleinstance=_9224_487 "sftp://root:Nh212345@10.1.16.248/" "-hostkey=ssh-ed25519 256 9SS0Zzzl1Qyj30dK0k50tu47cnVgD2C1tn6y/x0Ns7A=" "/log=C:\winscp.log" "/loglevel=2*"
. 2018-06-15 20:44:42.397 Switch:    /console=5.13.2
. 2018-06-15 20:44:42.397 Switch:    /consoleinstance=_9224_487
. 2018-06-15 20:44:42.397 Parameter: sftp://root:Nh212345@10.1.16.248/
. 2018-06-15 20:44:42.397 Switch:    /hostkey=ssh-ed25519 256 9SS0Zzzl1Qyj30dK0k50tu47cnVgD2C1tn6y/x0Ns7A=
. 2018-06-15 20:44:42.397 Switch:    /log=C:\winscp.log
. 2018-06-15 20:44:42.397 Switch:    /loglevel=2*

Appreciate if anyone had a hint. Thanks.
martin

Re: Password with special characters invalid in batch program

@guest: A generic solution is to URL-encode all non-alpha numeric characters in the password.
If your utility in .NET-based, you can use Uri.EscapeDataString method.
https://learn.microsoft.com/en-us/dotnet/api/system.uri.escapedatastring

In recent versions of WinSCP, you can use -password switch, which does not need URL-encoding:
https://winscp.net/eng/docs/scriptcommand_open#password
Though that's still not generic, as some characters are special in WinSCP scripting (like double quotes and percent signs). And if specify commands on WinSCP command-line in a batch file, some characters are special in batch file too.
Guest

Re: Password with special characters invalid in batch program

@Martin, I will not know the special characters in the password beforehand as the utility I am creating can be used by multiple users. I want a generic solution if there is?
sam_boyz

Re: Password with special characters invalid in batch program

Martin,

I have a password like <test12;:&>

I am using batch file.

I am enclosing the session URL in double quotes as below:
open "sam:<test12;:&>@myserver" -hostkey=*

I am still getting authentication failed error?
jtmorley

Re: Password with special characters invalid in batch program

I added the logging, but nothing else really popped up. I started looking into just using PuTTY's psftp option. I got closer with it, but still had trouble with the password. I then tried a suggestion from PuTTY. Long story short, by adding an extra % in front of each encoded character fixes the password special character problem. Example %2B becomes %%2B.
martin

Re: Password with special characters invalid in batch program

Turn on logging (with password logging enabled) both in scripting and GUI and compare the logs to see if you are missing something.
jtmorley

Re: Password with special characters invalid in batch program

I did see a post about encoding, and had already tried it. I did notice I missed one, and tried it again, but I'm still not able to get in. What else should I try?
jtmorley

Password with special characters invalid in batch program

I am running version 4.3.2 (Build 1201). I have other scripts running for a different site with a more normalized password. I'm wondering if a password in this format (not the actual password I'm using, but similar) with all the special characters is causing the problem. I tried a couple variations of putting quotes around it, but it failed also. I can get in thru the GUI tool, and from command line. I just can't get it to work from a batch program.
Thanks
C:\cmd>winscp myUserName:t,!wx1`]+J1H@companyInfo.com:2 /script=getStuff.bat

Searching for host...
Connecting to host...
Authenticating...
Using username "myUserName".
Authenticating with pre-entered password.
Access denied.
Connection has been unexpectedly closed. Server sent command exit status 0.
Authentication log (see session log for details):
Using username "myUserName".
Access denied.

Authentication failed.
transfer        ascii
No session.
C:\cmd>