<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WSLtty &#8211; Sandy Scott&#039;s Web Spot</title>
	<atom:link href="https://www.sandyscott.net/tag/wsltty/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sandyscott.net</link>
	<description>My little corner of the web</description>
	<lastBuildDate>Thu, 14 May 2020 07:27:59 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>Copy/Paste from Linux to Windows via SSH</title>
		<link>https://www.sandyscott.net/2020/05/copy-paste-from-linux-to-windows-via-ssh/</link>
					<comments>https://www.sandyscott.net/2020/05/copy-paste-from-linux-to-windows-via-ssh/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Sun, 10 May 2020 21:43:26 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[VcXsrv]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[WSL]]></category>
		<category><![CDATA[WSLtty]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=296</guid>

					<description><![CDATA[Ever wanted to copy and paste from a Linux machine you&#8217;re SSH&#8217;d into? Then read on! If you haven&#8217;t done already, take a look at my previous post to use wsltty to view the local WSL installation, which is then used to ssh into a remote box. For the purpose...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/05/copy-paste-from-linux-to-windows-via-ssh/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p>Ever wanted to copy and paste from a Linux machine you&#8217;re SSH&#8217;d into? Then read on!</p>



<p>If you haven&#8217;t done already, take a look at <a href="https://www.sandyscott.net/2020/05/03/best-ssh-setup-for-windows/">my previous post to use wsltty to view the local WSL installation, which is then used to ssh into a remote box.</a></p>



<p>For the purpose of this explanation the <strong>client </strong>is the machine you&#8217;re sitting at, and the <strong>server </strong>is the remote machine you&#8217;re connecting to.</p>



<p>First, we need to get SSH X11 Forwarding working. This would normally be used for running graphical applications, but we&#8217;re just using it for the clipboard feature.</p>



<h2 class="wp-block-heading">Server Configuration</h2>



<p>You should have these lines uncommented in <code>/etc/ssh/sshd_config</code></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;properties&quot;,&quot;mime&quot;:&quot;text/x-properties&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Properties files&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;properties&quot;}">X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no</pre></div>



<p>When you&#8217;re done restart the ssh daemon, on my (Debian) system the command is this:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo systemctl restart ssh</pre></div>



<p>If you&#8217;re running a firewall on the server you need to enable loopback. I&#8217;m using iptables, so this is how I&#8217;d do it:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo iptables -I INPUT -i lo -j ACCEPT
sudo iptables -I OUTPUT -o lo -j ACCEPT
su -
iptables-save &gt; /etc/iptables/rules.v4
exit</pre></div>



<h2 class="wp-block-heading">Client configuration</h2>



<p>From within WSL (but not ssh&#8217;d into a remote system), Install xauth and xterm:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo apt install xauth xterm</pre></div>



<p>A big thanks to this video for help with the next section: <a href="https://www.youtube.com/watch?v=_MgrjgQqDcE">youtube.com/watch?v=_MgrjgQqDcE</a></p>



<p>In Windows, download and install VcXsrv <a href="https://sourceforge.net/projects/vcxsrv/">https://sourceforge.net/projects/vcxsrv/</a></p>



<p>Find XLaunch in the start menu and run it. </p>



<p>On the first screen choose <strong>Multiple Windows</strong> and set the <strong>Display number</strong> to 0:</p>



<figure class="wp-block-image size-large is-resized"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image.png"><img decoding="async" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image.png" alt="" class="wp-image-302" width="250" height="196" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image.png 499w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-300x236.png 300w" sizes="(max-width: 250px) 100vw, 250px" /></a></figure>



<p>Choose <strong>Start no client</strong> on the next page:</p>



<figure class="wp-block-image is-resized"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-1.png"><img decoding="async" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-1.png" alt="" class="wp-image-303" width="250" height="196" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-1.png 499w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-1-300x236.png 300w" sizes="(max-width: 250px) 100vw, 250px" /></a></figure>



<p>Make sure <strong>Clipboard</strong> is turned on</p>



<figure class="wp-block-image size-large is-resized"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-2.png"><img decoding="async" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-2.png" alt="" class="wp-image-304" width="250" height="196" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-2.png 499w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-2-300x236.png 300w" sizes="(max-width: 250px) 100vw, 250px" /></a></figure>



<p>Press <strong>Save configuration</strong>. </p>



<figure class="wp-block-image size-large is-resized"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-3.png"><img loading="lazy" decoding="async" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-3.png" alt="" class="wp-image-305" width="250" height="196" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-3.png 499w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-3-300x236.png 300w" sizes="(max-width: 250px) 100vw, 250px" /></a></figure>



<p>Type <strong>shell:startup</strong> in the address bar and hit enter &#8211; this will take you to a special folder &#8211; files saved here will run when a user logs in. The filename should be pre-populated as <strong>config.xlaunch</strong>. That&#8217;s OK so hit <strong>Save</strong>, and then <strong>Finish</strong> in the previous window.</p>



<figure class="wp-block-image size-large is-resized"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-5.png"><img loading="lazy" decoding="async" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-5.png" alt="" class="wp-image-331" width="347" height="211" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-5.png 694w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-5-300x182.png 300w" sizes="(max-width: 347px) 100vw, 347px" /></a></figure>



<p>Finally, go back to WSL. This command tells your local WSL (the client) where to find the display. SSH uses that information when you link to the remote computer (server).</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">export DISPLAY=localhost:0</pre></div>



<p>You can also save this line into <code>~/.bashrc</code> on the client to load it every time WSL starts.</p>



<h2 class="wp-block-heading">Connect and Test</h2>



<p>In WSL, connect to the server with a slightly modified command:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">ssh -Y joebloggs@remotelinuxcomputer.example.com</pre></div>



<p>The <strong>-Y</strong> tells ssh you want to link the server to the VcXsrv software, so the server can display things on the client&#8217;s screen.</p>



<p>Let&#8217;s test with xeyes</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo apt install xeyes
xeyes</pre></div>



<p>A pair of eyes should appear on your screen, and follow the mouse around.</p>



<h2 class="wp-block-heading">Put it to use!</h2>



<p>So, what we have now is that anything that goes onto the Linux system clipboard (xclip) should end up on the Windows clipboard too. Lets give it a try. Pipe some data to xclip:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">echo &quot;I'm copied, paste me!&quot; | xclip -i</pre></div>



<p>Now try pasting that into a text editor on windows.</p>



<p>Next, copy some text in windows, then go back to your ssh session and type:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">xclip -o</pre></div>



<p>The text you copied should appear on a new line in the terminal.</p>



<p>The real power of this comes when combined with terminal applications that are aware of the system clipboard. For me, I wanted to copy from <code>vim</code> in an ssh session, and then paste into windows. If you&#8217;re using a version of vim with enough features (I use <code>vim-gtk</code>), all you have to do is add this to your <code>~/.vimrc</code>:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">&quot; Yank goes to system clipboard, to aid with WSL copy/paste
set clipboard=unnamedplus</pre></div>



<p>Now, anything copied by the yank commands ends up in the windows clipboard too.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/05/copy-paste-from-linux-to-windows-via-ssh/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Best ssh setup for windows</title>
		<link>https://www.sandyscott.net/2020/05/best-ssh-setup-for-windows/</link>
					<comments>https://www.sandyscott.net/2020/05/best-ssh-setup-for-windows/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Sun, 03 May 2020 15:51:57 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mintty]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Windows Subsystem for Linux]]></category>
		<category><![CDATA[WSL]]></category>
		<category><![CDATA[WSLtty]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=280</guid>

					<description><![CDATA[I&#8217;ve tried quite a few different setups for administering my various linux boxen from Windows, and this is currently my favourite: Mintty for WSL (aka WSLtty). Here&#8217;s how to set it up. Install Windows Subsystem for Linux (WSL): Open Powershell as an administrator Enter this command:Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux When...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/05/best-ssh-setup-for-windows/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p>I&#8217;ve tried quite a few different setups for administering my various linux boxen from Windows, and this is currently my favourite: Mintty for WSL (aka WSLtty).</p>



<p>Here&#8217;s how to set it up.</p>



<h2 class="wp-block-heading">Install Windows Subsystem for Linux (WSL):</h2>



<ol class="wp-block-list"><li>Open Powershell as an administrator</li><li>Enter this command:<br><code>Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux</code></li><li>When it&#8217;s done, restart your computer.</li></ol>



<h2 class="wp-block-heading">Install Linux (on WSL)</h2>



<p>I recommend Debian &#8211; it&#8217;s well supported by the community, and a pretty lightweight install compared to some of the other choices.</p>



<p>For the local windows store</p>



<ol class="wp-block-list"><li>Open the Windows Store</li><li>Search for &#8220;Debian&#8221;</li><li>Click on Get</li><li>Click on Install</li></ol>



<p>Once it&#8217;s installed:</p>



<ol class="wp-block-list"><li>Find and click on the Debian app in your start menu</li><li>Wait for a moment, then set up a username for this local installation of linux. It&#8217;ll be slightly more convenient if you use the same username you have on your remote linux machines.</li><li>Exit the terminal: type:<br><code>exit</code><br>and press enter.</li></ol>



<p>This info came from <a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10">https://docs.microsoft.com/en-us/windows/wsl/install-win10</a></p>



<h2 class="wp-block-heading">Install WSLtty</h2>



<ol class="wp-block-list"><li>Go to <a href="https://github.com/mintty/wsltty/releases/latest">https://github.com/mintty/wsltty/releases/latest</a></li><li>Choose the right release for your system &#8211; unless you have a fairly old computer it&#8217;ll be the one ending in &#8220;x86_64.exe&#8221;</li><li>Download and install.</li><li>This app isn&#8217;t digitally signed in a way approved by Microsoft, so a warning will pop up (&#8220;Windows protected your PC&#8221;). Click <strong>More info</strong> then <strong>Run anyway</strong>.</li></ol>



<h2 class="wp-block-heading">Run and connect!</h2>



<p>Mintty should have installed a shortcut called &#8220;WSL Terminal&#8221; with the linux penguin icon, click on it and you&#8217;ll get a black terminal windows with prompt in the top left: <code>[your unix username]@[computer name]:~$</code></p>



<p>Let&#8217;s get your local linux system up to date:</p>



<ol class="wp-block-list"><li>Type <code>sudo apt update</code> then press enter.</li><li>Type in your local linux password (that you created earlier)</li><li><code>sudo apt upgrade</code>, then press <code>y</code> and enter when asked if you want to continue</li><li>It may take a little while, depending on the speed of your pc and internet connection.</li><li>Finally lets install ssh:<br><code>sudo apt install ssh</code></li></ol>



<p>Now we can connect to a remote linux computer:</p>



<p>If the username on the remote computer is the same as the one you created earlier, the command is:<br><code>ssh remotelinuxcomputer.example.com</code> or <code>ssh 192.168.2.1</code>, when you put in the computer&#8217;s name or ip address.</p>



<p>If the username is different, no problem, do this:<br><code>ssh joebloggs@remotelinuxcomputer.example.com</code><br>or<br><code>ssh joebloggs@192.168.2.1</code></p>



<p>In either case, you will probably get a warning about &#8220;the authenticity of the host xxxxx can&#8217;t be established&#8221;. Don&#8217;t worry, just type yes, then enter you password for the remote computer, and you&#8217;re in!</p>



<h2 class="wp-block-heading">One final tip</h2>



<p>If ssh into remote computers is all your do with this, then log out, the login command will be remembered by the shell, even if you reboot.<br>Next time you open the WSL terminal, press the &#8220;Up&#8221; as many times as you need to scroll through the command history and find the one you wanted.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/05/best-ssh-setup-for-windows/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
