This is the first part of the Availability Anywhere series. For your convenience you can find other parts using the links below:
Part 1 — Connecting to SSH tunnel automatically in Windows
Part 2 — Connecting to VPN automatically in Windows
Part 3 — How to enable PowerShell remoting in Windows
Part 4 — Fixing LogonUi hang
Part 5 — Various remote connection things
Part 6 — Task scheduler not running on next run date on Windows Home edition
Part 7 — gpedit.msc on Windows Home
Part 8 — Running interactive application on a remote server from shell
Part 9 — Poor man’s channel bonding for RDP
Part 10 — Slightly better poor man’s channel bonding for RDP
Part 11 — Keeping a channel fresh
Part 12 — FileProxy for avoiding VPN without split tunneling (also known as TCP over File System)
Part 13 — Optimizing FileProxy
Part 14 — TCP over Named Pipe
Part 15 — TCP over Serial Port
Part 16 — Forwarding port from host to docker
Part 17 — Splitting physical monitor into multiple
Part 18 — Binding same port for multiple docker containers
Part 19 — Banning RDP and SSH attacks
Part 20 — Nested full-tunnel VPN in another full-tunnel VPN with force tunnel mode
Part 21 — Fixed mstsc.exe broken UI
Part 22 — Customer Experience Improvement Program restarts
Part 23 — RDP over VR goggles with no PCVR
Part 24 — Make RDP retain position of windows and stop moving them around
Part 25 — Supercharge your VR experience
Part 26 — Working remotely like a pro
Availability Anywhere Part 27 — Tools for remote work from laptops and XR/VR/AR
Let’s say that you want to configure reverse tunnel for connecting to your laptop computer. How to do that so it is started automatically when you boot your machine and it is reliable? In this post I will describe my configuration which I use for almost 10 years now. It is old and I bet there are better solutions available but I wanted to use something built into Windows with minimal dependencies needed. I am using this since Windows 7 and it still works. It opens tunnels for me so I can RDP into my machine from any place in the world.
Kitty
First, you need to have an SSH tunnel. For that you can use Kitty, a fork of Putty which gives some more options. It can save password (if you want to go with it instead of keys) and has options for restarting.
Basically, I use this configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
DisableAltGr\0\ PortKnocking\\ SCPAutoPwd\0\ ACSinUTF\0\ Comment\\ CtrlTabSwitch\0\ Password\passwordHash\ ForegroundOnBell\0\ SaveWindowPos\0\ WindowState\0\ TermYPos\-1\ TermXPos\-1\ LogTimeRotation\0\ Folder\Default\ AutocommandOut\\ Autocommand\\ LogTimestamp\\ AntiIdle\test\ ScriptfileContent\\ Scriptfile\\ SFTPConnect\\ IconeFile\\ Icone\1\ SaveOnExit\0\ Fullscreen\0\ Maximize\0\ SendToTray\0\ TransparencyValue\0\ zDownloadDir\C%3A%5C\ szOptions\-e%20-v\ szCommand\sz\ rzOptions\-e%20-v\ rzCommand\rz\ CygtermCommand\\ Cygterm64\0\ CygtermAutoPath\1\ CygtermAltMetabit\0\ HyperlinkRegularExpression\(((https%3F%7Cftp)%3A%5C%2F%5C%2F)%7Cwww%5C.)(([0-9]+%5C.[0-9]+%5C.[0-9]+%5C.[0-9]+)%7Clocalhost%7C([a-zA-Z0-9%5C-]+%5C.)%2A[a-zA-Z0-9%5C-]+%5C.(com%7Cnet%7Corg%7Cinfo%7Cbiz%7Cgov%7Cname%7Cedu%7C[a-zA-Z][a-zA-Z]))(%3A[0-9]+)%3F((%5C%2F%7C%5C%3F)[^%20%22]%2A[^%20,;%5C.%3A%22%3E)])%3F\ HyperlinkRegularExpressionUseDefault\1\ HyperlinkBrowser\\ HyperlinkBrowserUseDefault\1\ HyperlinkUseCtrlClick\0\ HyperlinkUnderline\1\ FailureReconnect\1\ WakeupReconnect\1\ ScriptHalt\\ ScriptWait\\ ScriptTimeout\30\ ScriptExcept\0\ ScriptEnable\0\ ScriptCRLF\1\ ScriptCondUse\0\ ScriptCondLine\%3A\ ScriptCharDelay\0\ ScriptLineDelay\0\ ScriptMode\0\ ScriptFileName\\ SSHManualHostKeys\\ ConnectionSharingDownstream\1\ ConnectionSharingUpstream\1\ ConnectionSharing\0\ WindowClass\\ SerialFlowControl\1\ SerialParity\0\ SerialStopHalfbits\2\ SerialDataBits\8\ SerialSpeed\9600\ SerialLine\COM1\ ShadowBoldOffset\1\ ShadowBold\0\ WideBoldFontHeight\2048\ WideBoldFontCharSet\5276560\ WideBoldFontIsBold\3866820\ WideBoldFont\\ WideFontHeight\2048\ WideFontCharSet\5276484\ WideFontIsBold\3866820\ WideFont\\ BoldFontHeight\2048\ BoldFontCharSet\5276408\ BoldFontIsBold\3866820\ BoldFont\\ ScrollbarOnLeft\0\ LoginShell\1\ StampUtmp\1\ BugChanReq\0\ BugWinadj\0\ BugOldGex2\0\ BugMaxPkt2\0\ BugRekey2\0\ BugPKSessID2\0\ BugRSAPad2\0\ BugDeriveKey2\0\ BugHMAC2\0\ BugIgnore2\0\ BugRSA1\0\ BugPlainPW1\0\ BugIgnore1\0\ PortForwardings\R5524=localhost%3A3389,R5534=localhost%3A5985,R5544=localhost%3A5986,R5554=localhost%3A22\ RemotePortAcceptAll\1\ LocalPortAcceptAll\1\ X11AuthFile\\ X11AuthType\1\ X11Display\\ X11Forward\0\ BlinkText\0\ BCE\1\ LockSize\0\ EraseToScrollback\1\ ScrollOnDisp\1\ ScrollOnKey\0\ ScrollBarFullScreen\0\ ScrollBar\1\ CapsLockCyr\0\ Printer\\ UTF8Override\1\ CJKAmbigWide\0\ LineCodePage\UTF-8\ Wordness224\2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2\ Wordness192\2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2\ Wordness160\1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1\ Wordness128\1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1\ Wordness96\1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1\ Wordness64\1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,2\ Wordness32\0,1,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1\ Wordness0\0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\ MouseOverride\1\ RectSelect\0\ MouseIsXterm\0\ PasteRTF\0\ RawCNP\0\ Colour33\187,187,187\ Colour32\0,0,0\ Colour31\187,187,187\ Colour30\0,187,187\ Colour29\187,0,187\ Colour28\0,0,187\ Colour27\187,187,0\ Colour26\0,187,0\ Colour25\187,0,0\ Colour24\0,0,0\ Colour23\0,0,0\ Colour22\187,187,187\ Colour21\255,255,255\ Colour20\187,187,187\ Colour19\85,255,255\ Colour18\0,187,187\ Colour17\255,85,255\ Colour16\187,0,187\ Colour15\85,85,255\ Colour14\0,0,187\ Colour13\255,255,85\ Colour12\187,187,0\ Colour11\85,255,85\ Colour10\0,187,0\ Colour9\255,85,85\ Colour8\187,0,0\ Colour7\85,85,85\ Colour6\0,0,0\ Colour5\0,255,0\ Colour4\0,0,0\ Colour3\85,85,85\ Colour2\0,0,0\ Colour1\255,255,255\ Colour0\187,187,187\ SelectedAsColour\0\ UnderlinedAsColour\0\ BoldAsColourTest\1\ DisableBottomButtons\1\ WindowHasSysMenu\1\ WindowMaximizable\1\ WindowMinimizable\1\ WindowClosable\1\ BoldAsColour\1\ Xterm256Colour\1\ ANSIColour\1\ TryPalette\0\ UseSystemColours\0\ FontVTMode\4\ FontQuality\0\ FontHeight\10\ FontCharSet\0\ FontIsBold\0\ Font\Courier%20New\ TermHeight\24\ TermWidth\80\ WinTitle\\ WinNameAlways\1\ DisableBidi\0\ DisableArabicShaping\0\ CRImpliesLF\0\ LFImpliesCR\0\ AutoWrapMode\1\ DECOriginMode\0\ ScrollbackLines\200\ BellOverloadS\5000\ BellOverloadT\2000\ BellOverloadN\5\ BellOverload\1\ BellWaveFile\\ BeepInd\0\ Beep\1\ BlinkCur\0\ CurType\0\ WindowBorder\1\ SunkenEdge\0\ HideMousePtr\0\ FullScreenOnAltEnter\0\ AlwaysOnTop\0\ Answerback\KiTTY\ LocalEdit\2\ LocalEcho\2\ TelnetRet\1\ TelnetKey\0\ CtrlAltKeys\1\ ComposeKey\0\ AltOnly\0\ AltSpace\0\ AltF4\1\ NetHackKeypad\0\ ApplicationKeypad\0\ ApplicationCursorKeys\0\ NoRemoteCharset\0\ NoDBackspace\0\ RemoteQTitleAction\1\ NoRemoteClearScroll\0\ NoRemoteWinTitle\0\ NoAltScreen\0\ NoRemoteResize\0\ NoMouseReporting\0\ NoApplicationCursors\0\ NoApplicationKeys\0\ LinuxFunctionKeys\0\ RXVTHomeEnd\0\ BackspaceIsDelete\1\ PassiveTelnet\0\ RFCEnviron\0\ RemoteCommand\\ PublicKeyFile\\ SSH2DES\0\ LogHost\\ SshProt\3\ SshNoShell\0\ GSSCustom\\ GSSLibs\gssapi32,sspi,custom\ AuthGSSAPI\1\ AuthKI\1\ AuthTIS\0\ SshBanner\1\ SshNoAuth\0\ RekeyBytes\1G\ RekeyTime\60\ HostKey\ed25519,ecdsa,rsa,dsa,WARN\ KEX\ecdh,dh-gex-sha1,dh-group14-sha1,rsa,WARN,dh-group1-sha1\ Cipher\aes,chacha20,blowfish,3des,WARN,arcfour,des\ ChangeUsername\0\ GssapiFwd\0\ AgentFwd\0\ TryAgent\1\ Compression\0\ NoPTY\0\ LocalUserName\\ UserNameFromEnvironment\0\ UserName\afish\ Environment\\ ProxyLogToTerm\1\ ProxyTelnetCommand\connect%20%25host%20%25port%5Cn\ ProxyPassword\\ ProxyUsername\\ ProxyPort\80\ ProxyHost\proxy\ ProxyMethod\0\ ProxyLocalhost\0\ ProxyDNS\1\ ProxyExcludeList\\ AddressFamily\0\ TerminalModes\CS7=A,CS8=A,DISCARD=A,DSUSP=A,ECHO=A,ECHOCTL=A,ECHOE=A,ECHOK=A,ECHOKE=A,ECHONL=A,EOF=A,EOL=A,EOL2=A,ERASE=A,FLUSH=A,ICANON=A,ICRNL=A,IEXTEN=A,IGNCR=A,IGNPAR=A,IMAXBEL=A,INLCR=A,INPCK=A,INTR=A,ISIG=A,ISTRIP=A,IUCLC=A,IUTF8=A,IXANY=A,IXOFF=A,IXON=A,KILL=A,LNEXT=A,NOFLSH=A,OCRNL=A,OLCUC=A,ONLCR=A,ONLRET=A,ONOCR=A,OPOST=A,PARENB=A,PARMRK=A,PARODD=A,PENDIN=A,QUIT=A,REPRINT=A,START=A,STATUS=A,STOP=A,SUSP=A,SWTCH=A,TOSTOP=A,WERASE=A,XCASE=A\ TerminalSpeed\38400,38400\ TerminalType\xterm\ TCPKeepalives\1\ TCPNoDelay\1\ PingIntervalSecs\10\ PingInterval\0\ WarnOnClose\0\ CloseOnExit\2\ PortNumber\22\ Protocol\ssh\ SSHLogOmitData\0\ SSHLogOmitPasswords\1\ LogFlush\1\ LogFileClash\-1\ LogType\0\ LogFileName\putty.log\ HostName\host\ Present\1\ |
It’s quite big but there are only few important things which you need to configure:
In Window -> Behaviour deselect “Warn before closing window” to be sure.
In Connection set a keepalive to something like 10 and anti-idle string to something like test. Also, select to “reconnect on system wakeup” and “reconnect on connection failure”.
In Connection -> Data choose your username and password.
In Connection -> SSH -> Tunnels choose your ports. I am forwarding 3389 (RDP), 5985 and 5986 (PS Remoting), 22 (OpenSSH).
In Session choose “Always” for “Close window on exit”.
Make sure to connect manually at least once to accept the key and you should be good to go.
Task scheduler
Now you need to run this thing automatically on system start. I am using this script:
1 2 3 4 |
:start taskkill /F /IM kitty.exe kitty -load profile -send-to-tray -log putty.log goto start |
Save this as a bat file.
Next, I noticed that sometimes I cannot RDP to my machine using the same user which actually runs this script. So I create new user in the system (it can be a local one, no need to use domain one), give it permissions to kitty and session file, run session (to accept the key). Then I use this Task scheduler:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
<?xml version="1.0" encoding="UTF-16"?> <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo> <Date>2010-01-01T00:00:00.0000000</Date> <Author>Author</Author> </RegistrationInfo> <Triggers> <BootTrigger> <Enabled>true</Enabled> </BootTrigger> </Triggers> <Principals> <Principal id="Author"> <UserId>Author</UserId> <LogonType>Password</LogonType> <RunLevel>HighestAvailable</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>false</AllowHardTerminate> <StartWhenAvailable>true</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>PT0S</ExecutionTimeLimit> <Priority>7</Priority> <RestartOnFailure> <Interval>PT1M</Interval> <Count>999</Count> </RestartOnFailure> </Settings> <Actions Context="Author"> <Exec> <Command>starttunnel.bat</Command> </Exec> </Actions> </Task> |
Write this as an XML file, import to task scheduler, adjust paths, enter password for Author
user and restart the operating system. Make sure you enable history logging in Task Scheduler to have some logging in case of errors.