WinSCP openSSH cygwin / PuTTY replacement

Advertisement

Jan Catrysse
Guest

WinSCP openSSH cygwin / PuTTY replacement

Hello everyone,

I was looking for a descent PuTTY replacement, easily integrated with WinSCP. I found the Cygwin + openSSH being the best suited for my needs, but I lost way too much time finding out how to integrate in with WinSCP. I’m using nonstandard SSHd ports.

I just wanted to share the way I made it work, maybe it comes in handy. It was based on: https://winscp.net/eng/docs/integration_putty#openssh and http://blog.geekslikeshinythings.com/2013/08/winscp-and-cygwin.html

WinSCP options > PuTTY / Terminal client path =
<path_to_cygwin>\bin\mintty.exe --hold error ~/ssh.sh
Create file: ~\ssh.sh
#!/bin/bash -ile
PortNumber="`regtool get '\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\WinSCP%20temporary%20session\PortNumber'`"
HostName="`regtool get '\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\WinSCP%20temporary%20session\HostName'`"
UserName="`regtool get '\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\WinSCP%20temporary%20session\UserName'`"
PassWord="$4"

echo -e '\033]2;'$UserName@$HostName:$PortNumber'\007'
echo "USE PASSWORD: $PassWord"
# remove the # if you want to add / check the PublicKey at each login
#ssh-copy-id -p $PortNumber $UserName@$HostName
ssh -p $PortNumber $UserName@$HostName

At your own convenience add a shortcut to add a PublicKey (login w/o password). The command should be run after a first terminal session was started because it gets the info from the PuTTY session registry keys
WinSCP options: add local command:
<path_to_cygwin>\bin\mintty.exe --hold error ~/ssh_key.sh !P
Create file: ~\ssh_key.sh
#!/bin/bash -ile
PortNumber="`regtool get '\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\WinSCP%20temporary%20session\PortNumber'`"
HostName="`regtool get '\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\WinSCP%20temporary%20session\HostName'`"
UserName="`regtool get '\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\WinSCP%20temporary%20session\UserName'`"
PassWord="$1"

echo -e '\033]2;'$UserName@$HostName:$PortNumber'\007'
echo "$UserName@$HostName:$PortNumber"
echo "USE PASSWORD: $PassWord"

ssh-copy-id -p $PortNumber $UserName@$HostName

sleep 10
I hope it helps out anyone, all suggestions are welcome.

Reply with quote

Advertisement

You can post new topics in this forum