Topic "Send login & password to PuTTY"

Author Message
Limo

Guest


I think it could be very useful to login in a PuTTY session without typing the username in the PuTTY login window.

The password is already sent through the provided WinSCP option.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Username be sent also, if you have entered it already on login dialog.
_________________
Martin Prikryl
Limo

Guest


The username is correctly sent if you save it in the options of the server you want to connect to.

If you have a server stored without access data, WinSCP asks for username and password and, once connected, if you open a PuTTY session, it (PuTTY) will ask for the username.

Is it possible to send username and password to the PuTTY session without storing them in the server options?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
It is possible. I'll see if more people ask for it.
_________________
Martin Prikryl
WhiteTiger

Guest


Just change the way PuTTY integration works.
The current Integration isn't compatible with KiTTY in portable mode just because all informations are stored to the registry. (or any other portable PuTTY, except all who uses the registry as a fall back)
Just allow patterns for external applications so we can use something like this:
Code:
putty -pw "!P" !U@!@
kitty -pw "!P" -cmd "cd !/" !U@!@
kitty -pass "!P" -cmd "cd !/" !U@!@
(but i don't like the pattern style... what ever Very Happy)
Why using the registry anyway?

Of course, don't get the session informations from stored session files^^
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
WhiteTiger wrote:
Why using the registry anyway?

Not all session options can be passed via command-line.
Guest




prikryl wrote:
Not all session options can be passed via command-line.

...can they be passed with ini files? Do those "portable" versions use ini files?
Guest




up...
hansei

Guest


I want to support the idea of integration of a portable KiTTY.
Josef
[View user's profile]

Joined: 2011-04-10
Posts: 3
Location: Austria
I also only use KiTTY and WinSCP in portable mode.
Most of the time I just start KiTTY first and then WinSCP using Shift+F3, but it would be cool if it would work the other way around too.
scottyman2k

Guest


Hi guys
I'd rather use KiTTY than PuTTY, but want to manage all the connections from inside WinSCP
Loreto

Guest


I agree with scottyman2k.
Pmimarly I use Kitty.
I use putty only for the fact that winscp does not allow to pass parameters to an external application. I noticed that winscp passes the following parameters:
Code:
-pw password -load "WinSCP temporary session"

but nothing else.
For example it doesn't pass the userID.
If userID could be passed it would be enough to throw kitty.
For example:
Code:
-l userID -pass password -load "WinSCP temporary session"

So it's great if winscp could start other external applications over putty.
WhiteTiger
[View user's profile]

Joined: 2011-01-02
Posts: 7
Location: Germany
well... to be fair, I've wrote a wrapper application that starts KiTTY (and even sends the current remote path to it)
I've wrote it as I've posted my first post... actually I wanted to "upgrade" WinSCP but it's code is a mess xD And I'm only using real C/C++ so no Borland crap (which is the main reason I'm not able to do it directly for WinSCP, besides the code of course xD)

I can give you the wrapper... I wanted to post it anyway but it's not user friendly at all Razz Works for me but no one else xD
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
This request has been added to the tracker:
http://winscp.net/tracker/show_bug.cgi?id=966
WhiteTiger
[View user's profile]

Joined: 2011-01-02
Posts: 7
Location: Germany
well... my wrapper will be still of some use.. it gives KiTTY all informations it needs by command line, but it censors the command line once KiTTY is fully running (replaces the entire command line with "*", so using taskmgr will show something like "KiTTY.exe **************************************")
As we are talking about portable versions anyway, such security additions might be helpful. (not that I'm using my portable version outside my Computer/Home)

P.S. the code to "delete" the command line is actually based on code to retrieve the command line of other processes, but it does not only read it as it also overwrites it.
JBM

Guest


I would also like to add my name to those who want the password sent to Putty.
Simba
[View user's profile]
Donor
Joined: 2012-02-24
Posts: 20
Support for putty should be dropped. It's dead.

Please change it to kitty or provide us way to use kitty.


Thanks, Martin.


Simon.
Simba
[View user's profile]
Donor
Joined: 2012-02-24
Posts: 20
Hello Martin,

Please, it is time to make a move to Kitty. Putty is outdated.

I have tried creating custom command withing winscp to call kitty, but i cannot find a way to pass the port, so i always get Network connection refused.

As discussed in this post: http://winscp.net/forum/viewtopic.php?t=10623

Otherwise login info passed via parameters seems to work fine.

Thanks!
WhiteTiger
[View user's profile]

Joined: 2011-01-02
Posts: 7
Location: Germany
well.. Simba you might try my Putty wrapper for now... it's still not finished (and I'm not really developing it further as it works for me) but should work...

You'll have to setup WinSCP the way I require it though...
  • Options->Preferences...->Environment->Window->Show full path (checked)
  • extract PuTTY-Wrapper where your KiTTY.exe is
  • setup WinSCP to use PuTTY-Wrapper instead of PuTTY/KiTTY
    Options->Preferences...->Integration/Applications->PuTTY path

also, it deletes the registry entries for PuTTY / all SimonTatham products... that means your PuTTY settings if you're not using KiTTY in a portable way.
    HKEY_CURRENT_USER\Software\SimonTatham

so use it only with KiTTY or portable PuTTY (portable putty not tested.. as I pass KiTTY specific params) and don't use the registry to store PuTTY/KiTTY settings.

It's done in AutoIt and actually OpenSource... so I'll handle it out on request (and it's ugly as there's a lot of comments, unused crap and that like... As I said, not finished)

Last edited by WhiteTiger on 2013-05-12 13:34; edited 1 time in total
PuTTY-Wrapper.zip (435.74 KB) [Download]

Description: (none)

Simba
[View user's profile]
Donor
Joined: 2012-02-24
Posts: 20
Thanks for your response.
First time i got it working, but after it always: Network error: connection refused.

Maybe Martin could help us?
WhiteTiger
[View user's profile]

Joined: 2011-01-02
Posts: 7
Location: Germany
and you used my wrapper? (and it worked^^ wasn't that sure about that Razz)
Well... my wrapper passes the port to kitty... you could check the command line it passes.
For that: open taskmgr, set refresh rate to "high" and start KiTTY through WinSCP . You might be able to "capture" the command line that way before the wrapper deletes it.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
prikryl wrote:
This request has been added to the tracker:
http://winscp.net/tracker/show_bug.cgi?id=966

This has been implemented, in terms of custom command-like patterns.
Simba
[View user's profile]
Donor
Joined: 2012-02-24
Posts: 20
Actually i found very easy way.

On http://www.9bis.net/kitty/?action=forum&id=0202&PHPSESSID=154b21264af6e51feefd1395e2ce01f7

Quote:
The problem was that KiTTY is using a different key in the windows registry to store its settings.

For PuTTY you have:
[HKCU\Software\SimonTatham\PuTTY\*]

For KiTTY it's
[HKCU\Software\9bis.com\KiTTY\*]

So in order to launch a KiTTY session straight from WinSCP(portable) you need to edit WinSCP.ini

Just browse for the line:
PuttyRegistryStorageKey=Software%5CSimonTatham%5CPuTTY
and replace it with:
PuttyRegistryStorageKey=Software%5C9bis.com%5CKiTTY


Just make sure you are using NOT portable Kitty version.
After changing Winscp registry key, change path to Kitty.exe and it will work.
Simba
[View user's profile]
Donor
Joined: 2012-02-24
Posts: 20
Martin, my above post provides very simple solution.

Maybe you could add it for another users?

Thanks.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Simba wrote:
Martin, my above post provides very simple solution.

Maybe you could add it for another users?

Registry key is now configurable in GUI:
http://winscp.net/tracker/show_bug.cgi?id=1006

I'm sending you a dev version for testing.
Simba
[View user's profile]
Donor
Joined: 2012-02-24
Posts: 20
Tested and it's working perfectly.

Next step would be to rename Putty instances to "SSH client" (i believe in future there might arise new , even better alternatives).

Include dropdown - "Putty" or "Kitty"

Display Note "Portable Kitty version not supported".

And we are good to go.

Thanks!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Simba wrote:
Next step would be to rename Putty instances to "SSH client" (i believe in future there might arise new , even better alternatives).

It's still not generic enough to support any SSH client fully. It relies on registry keys format of PuTTY and its clones. but you can at least pass username, password and hostname to any SSH client that is able to accept them on command line (patterns !U, !P and !@).

Quote:
Display Note "Portable Kitty version not supported".

That contradicts your suggestion above, doesn't it? Anyway, even portably KiTTY is partially supported, when you use !U@!@ pattern to pass username and hostname.
_________________
Martin Prikryl
Simba
[View user's profile]
Donor
Joined: 2012-02-24
Posts: 20
Hi, Martin,

Well i doubt somebody will start from scratch. If somebody will decide to build another version, they probably would use putty sources. Same as Mozilla, bunch of Firefox spin-offs.

Problem with passing parameters, there does not seem to be a way to pass custom PORT, keeping in mind that first step securing your server is to change SSH port, makes this method useless.

Of course, it would be the best, if we could pass host, login info, PORT and even directory.
WhiteTiger
[View user's profile]

Joined: 2011-01-02
Posts: 7
Location: Germany
what's wrong with my wrapper Razz
It does all that... passes "port", "directory" etc^^ Well... passing the directory is a bit hacky as WinSCP has no support for that one.
And even though I'm using my wrapper and I'm kind of happy with it, a native solution within WinSCP is preferred... (and faster/better directory change on KiTTY's part)
The worst thing about my wrapper is (besides the fact I haven't completed it) that it still has to read from registry and clean it afterwards... it leaves no tracks but still shouldn't be considered "portable"
Petr
[View user's profile]
Moderator
Joined: 2006-01-26
Posts: 50
Implemented in 5.2.2 beta and released today Smile
madburg
[View user's profile]

Joined: 2013-12-23
Posts: 1
WhiteTiger wrote:
It's done in AutoIt and actually OpenSource... so I'll handle it out on request (and it's ugly as there's a lot of comments, unused crap and that like... As I said, not finished)


WhiteTiger, would you be so kind and share the AutoIT code block(s) that re-write the process commandline, so no one can view the original process commandline (which contains the USR/PWD) in taskmgr.

Much appreciated.
WhiteTiger
[View user's profile]

Joined: 2011-01-02
Posts: 7
Location: Germany
this is no cleaned up version... as it's the code I've used and tested with Razz
It's part of my local __ProcessX.au3 I use for different kind of things...

Replace "<xXx>" with "s€x" and that "€" is an "E"
Code:

;~    https://www.autoitscript.com/forum/topic/88214-_winapi_getcommandlinefrompid-from-any-process/
;~ Func _WinAPI_GetCommandLineFromPID($iPID)
;~ If $iDELETE = replace CommandLine with "*" so no one can read it again (ProgramPath isn't replaced)
;~ If $iDELETE > 1 = even replace the ProgramPath
Func _ProcessGetCommandLine($iPID = @AutoItPID, $iDELETE = 0)
   Local $dwDesiredAccess = 0x0410; 0x0410 = PROCESS_VM_READ (0x0010) | PROCESS_QUERY_INFORMATION (0x0400)         0x0438 = && PROCESS_VM_OPERATION (0x0008) | PROCESS_VM_WRITE (0x0020)
   If $iDELETE Then
      $iDELETE = Int($iDELETE + 0);
      $dwDesiredAccess += 0x0028;
   EndIf
   Local $aCall = DllCall('Kernel32.dll', 'HANDLE', 'OpenProcess', _
         'DWORD', $dwDesiredAccess, _
         'BOOL', 0, _
         'DWORD', $iPID)
   If @error Or Not $aCall[0] Then
      Return SetError(1, 0, '')
   EndIf
   Local $hProcess = $aCall[0]
   Local $tPROCESS_BASIC_INFORMATION = DllStructCreate('dword_ptr ExitStatus;' & _
         'ptr PebBaseAddress;' & _
         'dword_ptr AffinityMask;' & _
         'dword_ptr BasePriority;' & _
         'dword_ptr UniqueProcessId;' & _
         'dword_ptr InheritedFromUniqueProcessId')
   $aCall = DllCall('ntdll.dll', 'int', 'NtQueryInformationProcess', _
         'handle', $hProcess, _
         'dword', 0, _ ; ProcessBasicInformation
         'ptr', DllStructGetPtr($tPROCESS_BASIC_INFORMATION), _
         'dword', DllStructGetSize($tPROCESS_BASIC_INFORMATION), _
         'dword*', 0)
   If @error Then
      DllCall('Kernel32.dll', 'bool', 'CloseHandle', 'handle', $hProcess)
      Return SetError(2, 0, '')
   EndIf
   Local $tPEB = DllStructCreate('byte InheritedAddressSpace;' & _
         'byte ReadImageFileExecOptions;' & _
         'byte BeingDebugged;' & _
         'byte Spare;' & _
         'ptr Mutant;' & _
         'ptr ImageBaseAddress;' & _
         'ptr LoaderData;' & _
         'ptr ProcessParameters;' & _
         'ptr SubSystemData;' & _
         'ptr ProcessHeap;' & _
         'ptr FastPebLock;' & _
         'ptr FastPebLockRoutine;' & _
         'ptr FastPebUnlockRoutine;' & _
         'dword EnvironmentUpdateCount;' & _
         'ptr KernelCallbackTable;' & _
         'ptr EventLogSection;' & _
         'ptr EventLog;' & _
         'ptr FreeList;' & _
         'dword Tl<xXx>pansionCounter;' & _
         'ptr TlsBitmap;' & _
         'dword TlsBitmapBits[2];' & _
         'ptr ReadOnlySharedMemoryBase;' & _
         'ptr ReadOnlySharedMemoryHeap;' & _
         'ptr ReadOnlyStaticServerData;' & _
         'ptr AnsiCodePageData;' & _
         'ptr OemCodePageData;' & _
         'ptr UnicodeCaseTableData;' & _
         'dword NumberOfProcessors;' & _
         'dword NtGlobalFlag;' & _
         'ubyte Spare2[4];' & _
         'int64 CriticalSectionTimeout;' & _
         'dword HeapSegmentReserve;' & _
         'dword HeapSegmentCommit;' & _
         'dword HeapDeCommitTotalFreeThreshold;' & _
         'dword HeapDeCommitFreeBlockThreshold;' & _
         'dword NumberOfHeaps;' & _
         'dword MaximumNumberOfHeaps;' & _
         'ptr ProcessHeaps;' & _
         'ptr GdiSharedHandleTable;' & _
         'ptr ProcessStarterHelper;' & _
         'ptr GdiDCAttributeList;' & _
         'ptr LoaderLock;' & _
         'dword OSMajorVersion;' & _
         'dword OSMinorVersion;' & _
         'dword OSBuildNumber;' & _
         'dword OSPlatformId;' & _
         'dword ImageSubSystem;' & _
         'dword ImageSubSystemMajorVersion;' & _
         'dword ImageSubSystemMinorVersion;' & _
         'dword GdiHandleBuffer[34];' & _
         'dword PostProcessInitRoutine;' & _
         'dword Tl<xXx>pansionBitmap;' & _
         'byte Tl<xXx>pansionBitmapBits[128];' & _
         'dword SessionId')
   $aCall = DllCall('Kernel32.dll', 'bool', 'ReadProcessMemory', _
         'ptr', $hProcess, _
         'ptr', DllStructGetData($tPROCESS_BASIC_INFORMATION, 'PebBaseAddress'), _
         'ptr', DllStructGetPtr($tPEB), _
         'dword', DllStructGetSize($tPEB), _
         'dword*', 0)
   If @error Or Not $aCall[0] Then
      DllCall('Kernel32.dll', 'bool', 'CloseHandle', 'handle', $hProcess)
      Return SetError(3, 0, '')
   EndIf
   Local $tPROCESS_PARAMETERS = DllStructCreate('dword AllocationSize;' & _
         'dword ActualSize;' & _
         'dword Flags;' & _
         'dword Unknown1;' & _
         'word LengthUnknown2;' & _
         'word MaxLengthUnknown2;' & _
         'ptr Unknown2;' & _
         'handle InputHandle;' & _
         'handle OutputHandle;' & _
         'handle ErrorHandle;' & _
         'word LengthCurrentDirectory;' & _
         'word MaxLengthCurrentDirectory;' & _
         'ptr CurrentDirectory;' & _
         'handle CurrentDirectoryHandle;' & _
         'word LengthSearchPaths;' & _
         'word MaxLengthSearchPaths;' & _
         'ptr SearchPaths;' & _
         'word LengthApplicationName;' & _
         'word MaxLengthApplicationName;' & _
         'ptr ApplicationName;' & _
         'word LengthCommandLine;' & _
         'word MaxLengthCommandLine;' & _
         'ptr CommandLine;' & _
         'ptr EnvironmentBlock;' & _
         'dword Unknown[9];' & _
         'word LengthUnknown3;' & _
         'word MaxLengthUnknown3;' & _
         'ptr Unknown3;' & _
         'word LengthUnknown4;' & _
         'word MaxLengthUnknown4;' & _
         'ptr Unknown4;' & _
         'word LengthUnknown5;' & _
         'word MaxLengthUnknown5;' & _
         'ptr Unknown5;')
   $aCall = DllCall('Kernel32.dll', 'bool', 'ReadProcessMemory', _
         'ptr', $hProcess, _
         'ptr', DllStructGetData($tPEB, 'ProcessParameters'), _
         'ptr', DllStructGetPtr($tPROCESS_PARAMETERS), _
         'dword', DllStructGetSize($tPROCESS_PARAMETERS), _
         'dword*', 0)
   If @error Or Not $aCall[0] Then
      DllCall('Kernel32.dll', 'bool', 'CloseHandle', 'handle', $hProcess)
      Return SetError(4, 0, '')
   EndIf
   $aCall = DllCall('Kernel32.dll', 'bool', 'ReadProcessMemory', _
         'ptr', $hProcess, _
         'ptr', DllStructGetData($tPROCESS_PARAMETERS, 'CommandLine'), _
         'wstr', '', _
         'dword', DllStructGetData($tPROCESS_PARAMETERS, 'MaxLengthCommandLine'), _
         'dword*', 0)
   If @error Or Not $aCall[0] Then
      DllCall('Kernel32.dll', 'bool', 'CloseHandle', 'handle', $hProcess)
      Return SetError(5, 0, '')
   EndIf
   If $iDELETE Then
      Local $tmp = '';
      Local $tmp_len = DllStructGetData($tPROCESS_PARAMETERS, 'LengthCommandLine');
      Local $tmp_slen = ($tmp_len / 2)
      Local $tmp_nlen = 0;
      Local $pos = 0;
      If $iDELETE == 1 Then
         $pos = StringInStr($aCall[3], ' ');
         If $pos <> 0 Then
            Local $pos2 = StringInStr($aCall[3], '"');
            If $pos2 == 0 Or $pos < $pos2 Then
               $tmp = StringLeft($aCall[3], $pos);
            Else
               $pos2 = StringInStr($aCall[3], '"', 0, 2);
               $pos = StringInStr($aCall[3], ' ', 0, 1, $pos2);
               If $pos <> 0 Then
                  $tmp = StringLeft($aCall[3], $pos);
               Else
                  $pos = $tmp_slen;
               EndIf
            EndIf
         Else
            $pos = $tmp_slen;
         EndIf
      EndIf
;~       $tmp &= '/TUStart /pid:532';
      For $i = $pos To $tmp_slen
         $tmp &= '*';
      Next
      _WinAPI_WriteProcessMemory($hProcess, DllStructGetData($tPROCESS_PARAMETERS, 'CommandLine'), $tmp, $tmp_len, $tmp_nlen, 'wstr');
      If $tmp_nlen <> $tmp_len Then
;~          ConsoleWrite('WriteError!' & @LF);
         DllCall('Kernel32.dll', 'bool', 'CloseHandle', 'handle', $hProcess)
         Return SetError(0, 6, $aCall[3])
      EndIf
   EndIf
   DllCall('Kernel32.dll', 'bool', 'CloseHandle', 'handle', $hProcess)
   Return $aCall[3]
EndFunc   ;==>_ProcessGetCommandLine
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License