Password with special characters invalid in batch program

Advertisement

jtmorley
Joined:
Posts:
5

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>

Reply with quote

Advertisement

jtmorley
Joined:
Posts:
5

Re: Password with special characters invalid in batch program

martin wrote:

Please read documentation:
https://winscp.net/eng/docs/session_url

If that does not help, come back.


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?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
28,659
Location:
Prague, Czechia

Re: Password with special characters invalid in batch program

Turn on loggign both in scripting and GUI and compare the logs to see if you are missing something.
_________________
Martin Prikryl

Reply with quote

jtmorley
Joined:
Posts:
5

Re: Password with special characters invalid in batch program

martin wrote:

Turn on loggign both in scripting and GUI and compare the logs to see if you are missing something.

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
28,659
Location:
Prague, Czechia

Re: Password with special characters invalid in batch program

If you are running WinSCP from a batch file, then yes. You have not mentioned that.
_________________
Martin Prikryl

Reply with quote

jtmorley
Joined:
Posts:
5

Re: Password with special characters invalid in batch program

martin wrote:

If you are running WinSCP from a batch file, then yes. You have not mentioned that.

Yes I did. Please refer to first posting.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
28,659
Location:
Prague, Czechia

Re: Password with special characters invalid in batch program

Ok, sorry. Anyway, did it help?
_________________
Martin Prikryl

Reply with quote

jtmorley
Joined:
Posts:
5

Re: Password with special characters invalid in batch program

martin wrote:

Ok, sorry. Anyway, did it help?

Yes it did, thanks.

Reply with quote

Advertisement

sam_boyz
Guest

Re: Password with special characters invalid in batch program

martin wrote:

If you are running WinSCP from a batch file, then yes. You have not mentioned that.

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 auhthentication failed error?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
28,659
Location:
Prague, Czechia

Re: Password with special characters invalid in batch program

sam_boyz wrote:

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=*
You have to URL-encode the semicolon:
https://winscp.net/eng/docs/session_url

Reply with quote

Guest

Re: Password with special characters invalid in batch program

martin wrote:

sam_boyz wrote:

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=*
You have to URL-encode the semicolon:
https://winscp.net/eng/docs/session_url

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?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
28,659
Location:
Prague, Czechia

Re: Password with special characters invalid in batch program

Anonymous wrote:

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?
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://msdn.microsoft.com/en-us/library/system.uri.escapedatastring.aspx
_________________
Martin Prikryl

Reply with quote

Advertisement

pswong
Guest

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

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
28,659
Location:
Prague, Czechia

Re: password with special character

pswong wrote:

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="
Percent sign has special meaning in a batch file. If you want the batch file to pass percent sign to WinSCP, you have to double it: Nh212%%23%%24%%25p

You can have WinSCP generate a batch file with a correct syntax:
https://winscp.net/eng/docs/ui_generateurl#script

Reply with quote

Advertisement

You can post new topics in this forum