Topic "WinSCP openSSH cygwin / PuTTY replacement"

Author Message
Jan Catrysse

Guest


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 =
Code:
<path_to_cygwin>\bin\mintty.exe --hold error ~/ssh.sh

Create file: ~\ssh.sh
Code:
#!/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:
Code:
<path_to_cygwin>\bin\mintty.exe --hold error ~/ssh_key.sh !P

Create file: ~\ssh_key.sh
Code:
#!/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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Thanks for sharing this. The next version of WinSCP (5.8) will support !# pattern for port number:
https://winscp.net/tracker/show_bug.cgi?id=1020
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