# K95RELAY (SAMPLE VERSION): # Connects from K95 on Windows to an Internet host through an SSH relay # # Frank da Cruz # The Open Source Kermit Project # 10 April 2022 # Last update: Tue Apr 19 08:16:23 2022 # # Windows Kermit-95-to-Internet-host connection via ssh relay. Totally # password driven: covers the case where both the relay and the Internet host # are logged in to with a password. Many other combinations are possible, # e.g. public/private key exchange between the relay and the Internet host # and/or between Windows and the relay. The purpose of this script is simply # to show that whatever the authentication method, the process can be scripted # to mimic direct ssh login from Kermit 95 on Windows to the Internet host, # even when the host doesn't recognize K95's ssh ciphers. # # When the script starts it prompts you for the two passwords. # # To adapt this script to your own home network, change the definitions # in the first two sections and then make other adjustments as required. # # Note: The Internet server name (\m(fulltarget) is FICTIONAL. # ############################################################################# # User and computer names - CHANGE THESE # .relayuser = fdc # Username on relay .targetuser = fdc # Username on Internet computer .windowsuser = fdc # Username on Windows .relay := \m(relayuser)-Ubuntu # Relay hostname on local network .fullrelay := \m(relay).home # Full domain name of relay .fulltarget = server1.somehost.com # Internet destination domain name # Prompts, responses, and directories - CHANGE THESE IF NECESSARY # .relayshellprompt := [~]\32 # Relay shell prompt to wait for .relaybadpassword := "Login incorrect" .targetpassprompt := "Password: " .defaultdirectory := C:/Users/\m(windowsuser)/tmp/ # Default Windows directory .keepalive = 0 # Change this to 1 if you get "broken pipe" errors # Other parameters derived from the user and computer names specified above # .shortrelay := \fupper(\fword(\m(relay),2,-)) # (for messages) .shorttarget := \fword(\m(fulltarget),1) # (for messages) .banner := \fcapitalize(\m(shorttarget)) via \m(relay) # Banner for window if \m(keepalive) { .sshcmd1 := ssh -l \m(targetuser) -e none .sshcmd2 = -o TCPKeepAlive=yes -o ServerAliveCountMax=20 .sshcmd3 = -o ServerAliveInterval=15 .sshcommand := \m(sshcmd1) \m(sshcmd2) \m(sshcmd3) \m(fulltarget) } else { .sshcommand := "ssh -l \m(targetuser) -e none \m(fulltarget)" } set title \m(banner) # Write window-frame banner cd \m(defaultdirectory) # CD to desired Windows directory if fail end 1 "cd \m(defaultdirectory) failed" # Operational customizations - Colors, size, font, appearance, etc. # set command color white black # Command screen color set term color term lgray blue # Terminal screen color set terminal character-set utf8 # UTF-8 character encoding set term apc unchecked # Application Program Command set term width 80 # Screen dimensions: 80 chars wide set term height 45 # and 45 lines high set terminal font courier_new 10 # Font and size (points) set gui window position 140 200 # Where to put window on PC screen set terminal autodownload on # Allow autodownload set terminal scrollback 12000 # Allocate a big scrollback buffer # Collect passwords... undef _yy while not def _yy { # Prompt for relay password askq _yy {\m(shortrelay) password: } } undef _zz while not def _zz { # Prompt for Internet host password askq _zz {\m(shorttarget) password: } } # Connect to relay and log in # echo LOGGING IN TO RELAY \fupper(\m(shortrelay))... set telnet auth type none # Clear-text Telnet to relay set host \m(fullrelay) telnet # Connect but stay in command mode input 10 Password:\32 # Wait for password prompt if success lineout \m(_yy) # Send password else end 1 "Relay password prompt not received" minput 10 {\m(relayshellprompt)} {\m(relaybadpassword)} switch \v(minput) { :0, echo, hangup, end 1 "Relay shell prompt not received" :1, break :2, echo, hangup, end 1 "FAILURE: Password not accepted" :default, end 1 "Problem with \m(shortrelay) login" } echo echo \m(shortrelay) LOGIN OK... # Connect from relay to target and log in. Host behaviors vary as to what # happens if the incorrect password is given so we just connect after sending # the password and see what happened. # echo echo LOGGING IN TO TARGET \fupper(\m(shorttarget))... lineout \m(sshcommand) # Send ssh command to relay input 10 \m(targetpassprompt) # Wait for target password prompt if fail end 1 "Target password prompt not received: \m(targetpassprompt)" msleep 100 # Brief pause lineout \m(_zz) # Send password echo if open connection echo "\fupper(\m(shorttarget)) CONNECTION OK" else end 1 "\fupper(\m(shorttarget)) CONNECTION FAILED" connect # Open terminal window to target end 0 # return code 0 = success ; Local Variables: ; comment-column:40 ; comment-start:"# " ; End: