Class powershell and secureString

When trying to access an FTP site, I can use a simple text password in the credentials, and it works fine, but when I use SecureString, it cannot authenticate. Examples:

$pw = "mypw"
$ftp = [system.net.ftpwebrequest] [system.net.webrequest]::create("ftp:myserver")
$ftp.Credentials  = new-object system.net.networkcredential("myuid", $pw)

works great. But the following errors

$pw = "mypw"
$ftp = [system.net.ftpwebrequest] [system.net.webrequest]::create("ftp:myserver")
$ss = convertto-securestring -asplaintext -force $pw
$ftp.Credentials  = new-object system.net.networkcredential("myuid", $ss)

But this fails authentication. What? I do not understand?

(BTW I know that I do not need the plaintext pw in my script. This is just an example.)

+3
source share
2 answers

This is because FTP cannot handle anything other than a normal username and password unless you use secure FTP. Is there any confusion here?

+3
source

"ftp", "security", ftp, - . ssh telnet, scp rcp, sftp ftp. , . , ftp , . ? .

+2

All Articles