Passing password to a script.

Advertisement

cscott952
Joined:
Posts:
2
Location:
Seattle, WA

Passing password to a script.

I am trying to create a script to upload files. My problem is that the server I am connecting to does not support providing a password via username:password@example.com. I have been trying to use an initialization file /ini as shown in the docs, but it doesn't work. So I have 2 questions.

1. How should I be passing a password to a script if the password can not be passed in the connection string.
2. Can a script use a ini file, or is that just for the GUI?

Thanks,
Casey

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,468
Location:
Prague, Czechia

Re: passing password to a script.

What does that mean? So how do you provide password to your server?

If you cannot explain, please post a log file.

Reply with quote

cscott952
Joined:
Posts:
2
Location:
Seattle, WA

When I try to connect as described, the connection gets closed.
winscp> open xxxxx:xxxxxx@ftp.somesite.com
Searching for host...
Connecting to host...
Authenticating...
Using username "xxxxx".
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 "xxxxx".
Access denied.

Authentication failed.
winscp>
The account information is correct. I can successfully connect when I don't supply password in the open statement, and supply it when prompted.

I was trying to use an .ini for this, but that doesn't seem to work. e.g.
winscp.com /ini=file.ini
file.ini containing:
[Sessions\Server]
HostName=ftp.somesite.com
UserName=xxxxxx
PasswordPlain=xxxxxxx
The .ini doesn't seem to be read. Should that work?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,468
Location:
Prague, Czechia

Please post a full log file showing the problem and another log file showing successful connection in interactive mode.

To generate log file, enable logging, log in to your server and do the operation and only the operation that causes the error. For posting extensive logs you may use pastebin or similar application. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.

Reply with quote

peterr
Guest

WinSCP scripting password

I am getting the same problem as described below, i.e. when prompted for a password I can connect and download the necessary files, but when i try to pass it in the open command, i.e.
open sftp://user:password@ftp.site
it always gives back
Access Denied.

Reply with quote

Advertisement

peterr
Guest

here are my logs

. 2009-12-30 13:27:17.172 --------------------------------------------------------------------------
. 2009-12-30 13:27:17.172 WinSCP Version 4.2.4 (Build 610) (OS 5.1.2600 Service Pack 3)
. 2009-12-30 13:27:17.172 Login time: Wednesday, December 30, 2009 1:27:17 PM
. 2009-12-30 13:27:17.172 --------------------------------------------------------------------------
. 2009-12-30 13:27:17.172 Session name: sftp@sfile.site.com
. 2009-12-30 13:27:17.172 Host name: sfile.site.com (Port: 22)
. 2009-12-30 13:27:17.172 User name: sftp (Password: Yes, Key file: No)
. 2009-12-30 13:27:17.172 Tunnel: No
. 2009-12-30 13:27:17.172 Transfer Protocol: SFTP
. 2009-12-30 13:27:17.172 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2009-12-30 13:27:17.172 Proxy: none
. 2009-12-30 13:27:17.172 SSH protocol version: 2; Compression: No
. 2009-12-30 13:27:17.172 Bypass authentication: No
. 2009-12-30 13:27:17.172 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2009-12-30 13:27:17.172 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2009-12-30 13:27:17.172 SSH Bugs: -,-,-,-,-,-,-,-,-
. 2009-12-30 13:27:17.172 SFTP Bugs: -,-
. 2009-12-30 13:27:17.172 Return code variable: Autodetect; Lookup user groups: Yes
. 2009-12-30 13:27:17.172 Shell: default, EOL: 0
. 2009-12-30 13:27:17.172 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2009-12-30 13:27:17.172 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2009-12-30 13:27:17.172 Local directory: default, Remote directory: home, Update: No, Cache: Yes
. 2009-12-30 13:27:17.172 Cache directory changes: Yes, Permanent: Yes
. 2009-12-30 13:27:17.172 DST mode: 1
. 2009-12-30 13:27:17.172 --------------------------------------------------------------------------
. 2009-12-30 13:27:17.172 Looking up host "sfile.site.com"
. 2009-12-30 13:27:17.172 Connecting to  port 22
. 2009-12-30 13:27:20.408 Server version: SSH-2.0-1.82 sshlib: sshlibSrSshServer 1.00
. 2009-12-30 13:27:20.408 Using SSH protocol version 2
. 2009-12-30 13:27:20.408 We claim version: SSH-2.0-WinSCP_release_4.2.4
. 2009-12-30 13:27:20.564 Doing Diffie-Hellman group exchange
. 2009-12-30 13:27:21.033 Doing Diffie-Hellman key exchange with hash SHA-1
. 2009-12-30 13:27:21.314 Host key fingerprint is:
. 2009-12-30 13:27:21.314 Initialised AES-256 CBC client->server encryption
. 2009-12-30 13:27:21.314 Initialised HMAC-SHA1 client->server MAC algorithm
. 2009-12-30 13:27:21.314 Initialised AES-256 CBC server->client encryption
. 2009-12-30 13:27:21.314 Initialised HMAC-SHA1 server->client MAC algorithm
! 2009-12-30 13:27:21.799 Using username "sftp".
. 2009-12-30 13:27:21.939 Prompt (6, SSH password, , &Password: )
. 2009-12-30 13:27:21.939 Using stored password.
. 2009-12-30 13:27:21.939 Sent password
! 2009-12-30 13:27:22.174 Access denied
. 2009-12-30 13:27:22.174 Access denied
. 2009-12-30 13:27:22.174 Prompt (6, SSH password, , &Password: )
. 2009-12-30 13:27:22.174 Disconnected: Unable to authenticate

Reply with quote

martin
Site Admin
martin avatar

Re: WinSCP scripting password

@peterr: Are there any special characters in your password? Such as colon, slash, etc... You need to URL-encode them. Please read FAQ. If that does not help, come back.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum