<?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>Geek Republic &#187; Putty</title>
	<atom:link href="http://www.geek-republic.com/tag/putty/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geek-republic.com</link>
	<description>...in Geek we trust</description>
	<lastBuildDate>Tue, 07 Feb 2012 18:45:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Fix Your Linux Terminal Line Wrap Issues</title>
		<link>http://www.geek-republic.com/2009/04/03/fix-your-linux-terminal-line-wrap-issues/</link>
		<comments>http://www.geek-republic.com/2009/04/03/fix-your-linux-terminal-line-wrap-issues/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 15:00:39 +0000</pubDate>
		<dc:creator>Mike Nathan</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Putty]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://drnathan.teamhackaday.com/?p=293</guid>
		<description><![CDATA[I had a strange problem with Putty when connecting to a Linux server that I work on from time to time. Randomly, the command I was in the middle of typing would wrap around on itself on the same line, overwriting what I had already typed. Aside from being generally annoying, it caused plenty of [...]]]></description>
			<content:encoded><![CDATA[<p>I had a strange problem with Putty when connecting to a Linux server that I work on from time to time.  Randomly, the command I was in the middle of typing would wrap around on itself on the same line, overwriting what I had already typed.  Aside from being generally annoying, it caused plenty of headaches when trying to issue longer commands.</p>
<p>The problem would always when entering long commands, but it would also sometimes cause the text to wrap after only 20 or so characters.  I figured something had to be wrong, and sure enough after a bit of reading, I found the culprit.</p>
<p>It seems that at some point I read a tutorial about how to customize the command prompt that offered tips on how to dynamically change the Putty window title as well.  That&#8217;s all fine and dandy, but the author left out a very important point; How to escape non-printing characters.  You see, the problem with my command prompt was that several non-printing characters were being entered on the line as part of the prompt, and the shell could not accurately determine where to wrap the line, when to add a new line, etc.</p>
<p>Here was my existing prompt:</p>
<pre class="brush: bash; highlight: [1]; light: true; title: ; notranslate">PS1=&quot;[\W]\$ \e]2;[\d \t]  [\w]\a&quot;</pre>
<p>What this does, according to the author, is create a prompt containing the relative path of the directory I am working in (the <strong>\W</strong>) surrounded by square brackets, and ending with a &#8220;$&#8221; sign.  The path looks like this:<br />
<strong>[www]$</strong> if I happen to be working in a directory named www &#8211; simple enough.</p>
<p>The second half of the command (the <strong>\e]2;[\d \t]  [\w]\a</strong>) causes the date and time to be displayed in square brackets (<strong>[\d \t]</strong>) followed by the full path that I am working on (<strong>[\w]</strong>).  The &#8220;<strong>\e]2;</strong>&#8221; and the &#8220;<strong>\a</strong>&#8221; are just commands that specify the fact that I wanted to change the window title rather than the command prompt.</p>
<p>The problem arises because even though the commands to change the window prompt are considered non-printing characters, the server would &#8220;display&#8221; them anyways, taking up room on my command line without my knowledge.  The simple fix is to surround the second portion of my prompt command with a pair of brackets used for specifying non-printing characters.  They are &#8220;<strong>\[</strong>" and "<strong>\]</strong>&#8220;, used to denote the beginning and end of the non-printing characters, respectively.</p>
<p>So, my new command looks like so:</p>
<pre class="brush: bash; highlight: [1]; light: true; title: ; notranslate">PS1=&quot;[\W]\$ \[\e]2;[\d \t]  [\w]\a\]&quot;</pre>
<p>Pretty subtle change, but it makes a world of difference.</p>
<p>So, if you are seeing some weird behavior when connected to a Linux box with Putty or any terminal client for that matter, take a closer look at your command prompt.  Added tweaks such as the window title changes I made along with any sort of color changes you might have made to your prompt are likely the culprit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geek-republic.com/2009/04/03/fix-your-linux-terminal-line-wrap-issues/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Securing Windows Remote Desktop with CopSSH</title>
		<link>http://www.geek-republic.com/2009/02/17/securing-windows-remote-desktop-with-copssh/</link>
		<comments>http://www.geek-republic.com/2009/02/17/securing-windows-remote-desktop-with-copssh/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 22:26:23 +0000</pubDate>
		<dc:creator>Mike Nathan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CopSSH]]></category>
		<category><![CDATA[Putty]]></category>
		<category><![CDATA[PuttyGen]]></category>
		<category><![CDATA[RDP]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[XP]]></category>

		<guid isPermaLink="false">http://drnathan.teamhackaday.com/?p=134</guid>
		<description><![CDATA[Download This Guide in PDF Format I like having the ability to remotely access my PC at home while I am away in case I want to grab an important file I have left there, or if I need to finish something I didn’t quite get around to.  For ages I simply set port forwarding [...]]]></description>
			<content:encoded><![CDATA[<h3 style="text-align: center;"><a href="http://www.geek-republic.com/wp-content/uploads/2009/02/securing-windows-remote-desktop-with-copssh.pdf">Download This Guide in PDF Format</a></h3>
<p>I like having the ability to remotely access my PC at home while I am away in case I want to grab an important file I have left there, or if I need to finish something I didn’t quite get around to.  For ages I simply set port forwarding on my router allowing port 3389 to be directed to my desktop PC, which let me connect to my computer using Microsoft Remote Desktop Protocol (RDP).  While this was not the most secure method of doing so, it worked, and I did not want to change how I did things.</p>
<p>That’s not to say that RDP is not secure – it does use 128 bit RC4 according to Microsoft.  However, with man-in-the-middle attacks being relatively easy to carry out, I thought there had to be a better (and more secure) way of connecting to my oh so precious home network.</p>
<p>In the end, I decided that I could route my RDP sessions through an SSH tunnel and sleep a little easier at night.  If you follow the directions below, you can too.</p>
<p>Going forward in this document, I will use the term “Server” to refer to the remote computer (in my case, my home PC) that we will be connecting to.  I will use the term “Client” to refer to my local computer, the computer I will be connecting from.</p>
<h3 style="text-align: center;"><span style="text-decoration: underline;">Installing CopSSH</span></h3>
<p>1)    Download <a href="http://www.itefix.no/i2/node/27">CopSSH</a>, <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">Putty and Puttygen</a>.</p>
<p>2)    Execute the CopSSH installer, click <strong>Next</strong> to proceed, then click <strong>I agree</strong> to accept the license agreement.</p>
<p style="text-align: center;"><img class="aligncenter" title="CopSSH Setup Page 1" src="http://www.geek-republic.com/wp-content/uploads/2009/02/cop1.jpg" alt="CopSSH Screen 1" width="503" height="387" /></p>
<p><span id="more-134"></span></p>
<p>3)    Select the installation directory as shown below. Click Install to proceed.</p>
<p><strong>Note:  With the release of CopSSH v2.0, the default installation directory has changed from C:\Program Files\CopSSH to C:\Program Files\ICW. </strong></p>
<p style="text-align: center;"><img class="aligncenter" title="Cop SSH Setup Page 2" src="http://www.geek-republic.com/wp-content/uploads/2009/02/cop2.jpg" alt="CopSSH Setup Page 2 - Destination Folder" width="503" height="387" /></p>
<p>4)    CopSSH requires that Windows add a Service Account in order to run CopSSH as a service.  Click Install at the Service Account prompt unless you want to change the user name CopSSH creates.</p>
<p style="text-align: center;"><a href="http://www.geek-republic.com/wp-content/uploads/2009/02/cop21.jpg"><img class="aligncenter size-full wp-image-159" title="Cop SSH Setup Page 3" src="http://www.geek-republic.com/wp-content/uploads/2009/02/cop21.jpg" alt="CopSSH Setup Page 3 - Service Configuration" width="503" height="387" /></a></p>
<p>5)    Once all of the files are copied and the service has been started, you will receive the following message stating that no users are enabled on the server.  This is a security precaution – you will need to manually activate each user who you wish to allow access via SSH.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://www.geek-republic.com/wp-content/uploads/2009/02/cop3.jpg" alt="CopSSH Screen 3" width="503" height="387" /></p>
<p>6)    To add a user, open the <strong>Start Menu</strong>, locate the CopSSH folder, and launch the<strong> Activate a User</strong> application.  Select the user you wish to activate from the drop down box shown.  Before you click <strong>Next</strong>, you can deselect the option to <strong>Create keys for public key authentication</strong> if you wish to generate the keys separately.  I will demonstrate how to generate keys separately, so deselect the box if you wish to follow along.</p>
<p style="text-align: center;"><a href="http://www.geek-republic.com/wp-content/uploads/2009/02/adduser.jpg"><img class="aligncenter size-full wp-image-165" title="CopSSH Add User Screen" src="http://www.geek-republic.com/wp-content/uploads/2009/02/adduser.jpg" alt="CopSSH Add User" width="503" height="393" /></a></p>
<p>7)    Upon clicking <strong>Next</strong>, you will receive a message stating that the selected user has been activated and can access the machine via SSH.</p>
<h3 style="text-align: center;"><span style="text-decoration: underline;">SSH Key Pair Generation</span></h3>
<p>1)    Start Puttygen, enter <strong>4096</strong> into the <strong>Number of bits in a generated key</strong> field, then click <strong>Generate</strong> to begin the key creation process.</p>
<p style="text-align: center;"><img class="aligncenter" title="PuttyGen" src="http://www.geek-republic.com/wp-content/uploads/2009/02/puttygen1.jpg" alt="Puttygen Screen 1" width="483" height="471" /></p>
<p>2)    Move the mouse as requested to add randomness to the key generation.  Once you have generated enough random movements, your key will be created.  Once the generation has finished, add a <strong>Key Comment</strong> if you wish, then enter a key passphrase two times as shown – the more complex, the better.</p>
<p style="text-align: center;"><img class="aligncenter" title="PuttyGen Random Data Generation" src="http://www.geek-republic.com/wp-content/uploads/2009/02/puttygen2.jpg" alt="PuttyGen Generate Random Data" width="483" height="471" /></p>
<p>3)    Highlight all of the text in the <strong>Public key for pasting into OpenSSH authorized_keys file </strong>box and paste the data into a text editor.  Save the file to the <strong>C:\Program Files\ICW\home\&lt;UserID&gt;\.ssh\</strong> folder on your Server, naming the file authorized_keys with no extension.</p>
<p>This naming is important unless you change the key file that CopSSH looks for in the SSHD configuration file.  For the Administrator account shown, you would save the file as:<br />
<strong>C:\Program Files\copssh\home\Administrator\.ssh\authorized_keys </strong></p>
<p><strong>Note:</strong> You cannot simply click the <strong>Save Public Key</strong> button to generate this file &#8211; CopSSH will not accept that file format as a key.  You must manually copy and paste the public key as noted above.</p>
<p style="text-align: center;"><img class="aligncenter" title="PuttyGen Key Generation" src="http://www.geek-republic.com/wp-content/uploads/2009/02/puttygen3.jpg" alt="PuttyGen Example Key" width="483" height="471" /></p>
<p>4)    Now click <strong>Save Private Key</strong>. save the private key then close Puttygen.  You will want to copy this key to any PC you are using as a Client, as it is required by Putty to make the connection to the SSH server.  I would suggest backing this key up so you do not have to repeat this process in the future.</p>
<h3 style="text-align: center;"><span style="text-decoration: underline;">Configuring CopSSH</span></h3>
<p>1)    Now we need to reconfigure CopSSH to use a port other than 22 for connectivity.  Changing the port number adds a bit of security through obfuscation to your SSH install.  Since port 22 is commonly used for SSH, changing the port in your installation makes it just a bit harder for someone looking to exploit something.</p>
<p>To change this setting, we need to open the SSHD configuration file.  It is located at<br />
<strong>C:\Program Files\ICW\etc\sshd_config</strong>. You can open it in Wordpad or any text editor.  Notepad really is not the right tool for this job.</p>
<p>2)    In the file, the first value you can change is <strong>Port</strong>.  Change it to something that you will remember, uncomment the line by removing the pound sign at the beginning of the line, then save and close the file.</p>
<p style="text-align: center;"><img class="aligncenter" title="SSHd Configuration" src="http://www.geek-republic.com/wp-content/uploads/2009/02/sshd_config.jpg" alt="sshd_config - Changing Service Port Number" width="590" height="385" /></p>
<p>3)    The next values you want to change control how users can authenticate to the SSH server.  This is a detail that I missed in my first write-up that an astute reader noticed was overlooked.</p>
<p>This configuration change is very important as it disallows any user from authenticating to your SSH server without a key file.  If you do not change these values, users can connect to the server simply using their logon name and regular password.</p>
<p>You need to enable the <strong>PasswordAuthentication</strong> and <strong>PermitEmptyPasswords</strong> settings by removing the pound sign to uncomment the line, and assigning a value of <strong>“no”</strong> to both settings.</p>
<p><img class="aligncenter size-full wp-image-290" title="password" src="http://www.geek-republic.com/wp-content/uploads/2009/03/password.jpg" alt="Set PasswordAuthentication and PermiteEmptyPasswords to no" width="648" height="361" /></p>
<p>4)    Now, restart the OpenSSHD service via Windows’ Services panel to allow the configuration changes to be applied.</p>
<p>5)    If you have a router with firewall capabilities installed, you should log on to the administration web page and forward the SSH port you just defined to the computer on which you installed CopSSH.  I will assume that you know what you are doing and let you take care of this on your own.</p>
<h3 style="text-align: center;"><span style="text-decoration: underline;">Configuring Putty</span></h3>
<p>Now we need to configure Putty to connect to our SSH server.  This is a pretty straightforward process that you should do on the remote computer from which you want to connect.</p>
<p>1)    Launch Putty.  Under <strong>Session</strong> settings, we will adjust 2 items:</p>
<p><strong>a) </strong> Set your <strong>Host Name or Host IP</strong> for connection.  I use DD-WRT on my router, and it supports DynDNS – so I just entered my DynDNS host name here.</p>
<p><strong>b) </strong> Set the <strong>Port</strong> number to reflect the port number you configured in the sshd_config file earlier.</p>
<p style="text-align: center;"><img class="aligncenter" title="Putty Server Configuration" src="http://www.geek-republic.com/wp-content/uploads/2009/02/putty1.jpg" alt="Putty Server Configuration - Enter Server Name and Port Number" width="456" height="442" /></p>
<p>2)    Under <strong>Connection -&gt; Data</strong>, we will adjust one item:</p>
<p><strong>a) </strong> Set the <strong>Auto-login Username</strong> value to reflect the user you enabled on the SSH server</p>
<p style="text-align: center;"><a title="Putty Screen 2" href="http://www.teamhackaday.com/wp-content/uploads/2008/04/putty2.jpg"><img class="aligncenter" title="Putty Login Details" src="http://www.geek-republic.com/wp-content/uploads/2009/02/putty2.jpg" alt="Putty Login Details - Enter Remote User Name" width="456" height="442" /></a></p>
<p>3)    Under the main <strong>SSH</strong> section, we will adjust two items:</p>
<p><strong>a) </strong> Check the <strong>Enable Compression</strong> box under <strong>Protocol Options</strong> section</p>
<p><strong>b) </strong> Select <strong>2 only</strong> under the <strong>Preferred SSH protocol version</strong> section</p>
<p style="text-align: center;"><img class="aligncenter" title="Putty SSH Protocol Options" src="http://www.geek-republic.com/wp-content/uploads/2009/02/putty3.jpg" alt="Putty  - Set SSH Protocol Options, Compression, SSH 2 Only" width="456" height="442" /></p>
<p>4)    Expand the <strong>SSH</strong> section and select <strong>Auth</strong>.  In this section, we will set the <strong>Private key file for authentication</strong> to the location of the <strong>private key</strong> you created earlier.</p>
<p style="text-align: center;"><img class="aligncenter" title="Putty Private Key" src="http://www.geek-republic.com/wp-content/uploads/2009/02/putty4.jpg" alt="Putty - Select Private Key" width="456" height="442" /></p>
<p>5)    Under the<strong> Tunnels </strong>section of the <strong>SSH</strong> section, we will establish the tunneling settings for your remote desktop sessions.  This where the real work gets done.</p>
<p>You must create an entry for each computer you want to connect to at the other end of the SSH tunnel.  To do this, you will need RDP enabled on the target computer, as well as the host name of the target computer.  Once you have entered the proper values, click <strong>Add</strong> to add the port forwarding to the configuration.</p>
<p style="text-align: center;"><img class="aligncenter" title="Putty Port Redirection" src="http://www.geek-republic.com/wp-content/uploads/2009/02/putty5.jpg" alt="Putty - Port Redirection - Enter host name and port number" width="456" height="442" /></p>
<p>In the previous picture, you should note two things:</p>
<p><strong>a) </strong> The <strong>Source port</strong> refers to the port you are connecting to on your local computer, i.e. the port that Putty will listen to for connections while you have the SSH tunnel established.  I usually set this to 3390 for the first host I want to RDP to, and then count up from there.</p>
<p><strong>b) </strong> In the <strong>Destination</strong> section, you will need to enter the name of the remote server you want to connect to, followed by a colon, then the RDP port number.  For hosts using the default Windows RDP configuration, this is always 3389.  If you have changed this value, adjust as necessary.</p>
<p>You can pretty much add as many hosts as you can keep straight in your head:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://www.geek-republic.com/wp-content/uploads/2009/02/putty6.jpg" alt="Putty Screen 6" width="456" height="442" /></p>
<p>5)  Return to the main <strong>Sessions</strong> section of Putty and give the configured session a name as seen below.  Click <strong>Save</strong> to save your configuration – it will then appear in the list of saved session configurations.</p>
<p style="text-align: center;"><img class="aligncenter" title="Putty Sessions" src="http://www.geek-republic.com/wp-content/uploads/2009/02/putty7.jpg" alt="Putty - Save Session Information" width="456" height="442" /></p>
<p>6)    Finally, when you want to RDP into your remote computer, you can launch the Putty console to establish the connection, or you can simply run <strong>“putty.exe –load &lt;session name here&gt;”</strong> from the command line to launch Putty and connect to your remote host.  For example, I would type <strong>“putty.exe –load Home Network”</strong> if I wanted to launch this particular connection.</p>
<p>7)    After you authenticate using the passphrase you created earlier, you can simply RDP into your remote computer by connecting to <strong>localhost:3390</strong> from the Remote Desktop Connection application as shown below:</p>
<p style="text-align: center;"><img class="aligncenter" title="Windows Remote Desktop" src="http://www.geek-republic.com/wp-content/uploads/2009/02/rdp.jpg" alt="RDP to Local Machine" width="411" height="183" /></p>
<p><strong>Note: </strong>You can always test SSH connectivity locally by replacing your SSH host’s IP address with <strong>localhost</strong> and launching Putty.  In fact, I recommend you do this to ensure that your key pair is working properly before you attempt to connect remotely.</p>
<h3 style="text-align: center;"><strong> </strong><span style="text-decoration: underline;">Tunneling for VNC</span></h3>
<p>Some people have inquired as to whether or not you can secure VNC in the same fashion as Windows RDP.  The answer is “Absolutely”.  To do so, pick any Source Port you like, and substitute <strong>5900</strong> as the destination port number for the remote server.  It’s as simple as that.</p>
<p>The next time you fire up VNC, you merely need to enter <strong>localhost</strong> as the host name, followed by a colon, then the port number you picked.</p>
<p><strong>Note: </strong>This process can get tricky depending on the VNC client you are using.</p>
<p>For instance, TightVNC uses a strange port numbering system where you need to subtract <strong>5900</strong> from the port number you wish to connect to if it is different than port 5900.  As an example, if I was connecting to port <strong>5901</strong> on my local machine, I would enter<strong> localhost:1</strong> as the VNC server address.  If instead I selected port <strong>222</strong> as my tunneling port, I would enter <strong>localhost:-5678 </strong>as the VNC server address (Yes, that is a negative port number).</p>
<p style="text-align: center;"><a href="http://www.geek-republic.com/wp-content/uploads/2009/02/vnc.jpg"><img class="aligncenter size-full wp-image-163" title="VNC Tunneling" src="http://www.geek-republic.com/wp-content/uploads/2009/02/vnc.jpg" alt="Tunnel Settings for TightVNC" width="386" height="164" /></a></p>
<p>Hopefully this document helped you in your journey to safer, more secure remote communications.  If you have any questions, comments, or additions, please drop by <a href="http://www.geek-republic.com/chat">http://geek-republic.com/chat</a> and ask for DrNathan.  I’m usually there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geek-republic.com/2009/02/17/securing-windows-remote-desktop-with-copssh/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

