Hi Martin,
thanks for your great work! I'm the author of WinSSHTerm, which makes heavy use of WinSCP's and PuTTY's command line parameters. I just successfully changed the implementation from using
-pw
to
-pwfile
for opening PuTTY sessions.
Please let me explain how I did this. It will show my use case. Instead of creating a usual file in the file system, writing the password into it, passing its path to the
-pwfile
parameter and finally deleting it somehow, I took advantage of Windows' named pipes (motivated by this question on StackOverflow
Securely pass password to PuTTY process on start). Pipes can be accessed like a file, but in a more secure way:
Named pipes are similar to files, but they are stored in shared memory:
- At latest after the system reboots, named pipes are definitively deleted. Files on the file system however persist. So in case the password file would not get deleted accidently we would have a file containing a password inside lying around on the filesystem
- Even if we delete the password file on the file system, it is possible to recover the file as its content won't be deleted at once (this is how NTFS works)
Named pipes support a server/client concept. This is how WinSSHTerm uses it when opening a PuTTY session, that uses a password as authentication:
- A named pipe is created with a random name, let's reference to it with
mypipe
for simplicity. The file is now accessible by the URL \\.\pipe\mypipe
- Now WinSSHTerm (the server for the named pipe) waits for a client to connect, that is – PuTTY accesses the pipe for reading
- PuTTY gets launched with
-pwfile \\.\pipe\mypipe
and accesses the pipe to read the password
- WinSSHTerm will detect the client connection, and will now write the password into the pipe and then disconnect from it – note that until the client connects, the pipe is empty
- PuTTY will read the password from the pipe and complete the read operation by disconnecting from it
- Now there is no process connected to the pipe any more, which means the pipe gets automatically deleted
So my use case for the command line parameter
-pwfile
would be a secure way to communicate the password to WinSCP (more secure than e.g. using
WinSCP.ini
). It would be great if WinSCP would also support that.
Regards,
Patrick