<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Imran&#039;s Blog</title>
	<atom:link href="http://imranceh.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://imranceh.wordpress.com</link>
	<description>Every exit is an entry somewhere</description>
	<lastBuildDate>Thu, 03 May 2012 15:35:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='imranceh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Imran&#039;s Blog</title>
		<link>http://imranceh.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://imranceh.wordpress.com/osd.xml" title="Imran&#039;s Blog" />
	<atom:link rel='hub' href='http://imranceh.wordpress.com/?pushpress=hub'/>
		<item>
		<title>SSH Swiss army knife</title>
		<link>http://imranceh.wordpress.com/2011/05/04/ssh-swiss-army-knife/</link>
		<comments>http://imranceh.wordpress.com/2011/05/04/ssh-swiss-army-knife/#comments</comments>
		<pubDate>Wed, 04 May 2011 03:48:41 +0000</pubDate>
		<dc:creator>Imran</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://imranceh.wordpress.com/2011/05/04/ssh-swiss-army-knife/</guid>
		<description><![CDATA[SSH aka secure shell is Swiss army knife. Its astonishing how ssh can do wide variety of things from remote login to tunneling. In this tutorial im going to write about different things we can do with SSH. It can do many more things but i will discuss 1. Remote login 2. Password less login [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=imranceh.wordpress.com&amp;blog=11361731&amp;post=43&amp;subd=imranceh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>SSH aka secure shell is Swiss army knife. Its astonishing how ssh can do wide variety of things from remote login to tunneling. In this tutorial im going to write about different things we can do with SSH.</p>
<p>It can do many more things but i will discuss</p>
<p>1. Remote login</p>
<p>2. Password less login</p>
<p>3. Remote command execution</p>
<p>4. Xorg Forwarding</p>
<p>5. File Transfer (SCP)</p>
<p>6. Remote File system mount (SSHFS )</p>
<p>Lets dive into the awesome world of SSH <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Before we start , we need to have a ssh client and ssh server to connect to.Just install them from your favorite distribution&#8217;s repo</p>
<p><strong>Remote Login:</strong></p>
<p>The most common use of ssh is remote login, and i strongly believe ssh is the only widely used and secure way of remote login.</p>
<p>Lets see the commands,</p>
<p>consider we want to login into a remote server(my-ssh-server.com) running ssh-server ( default port for ssh is 22)</p>
<blockquote><p>ssh user@my-ssh-server.com</p></blockquote>
<p>If the ssh server is running on a different port we can specify the port number using -p option</p>
<blockquote><p>ssh user@my-ssh-server.com -p 2222</p></blockquote>
<p>In the above example, a connection will be made on port 2222 on my-ssh-server.com.</p>
<p>Generally ssh asks for user credentials, a username and password to login you in.</p>
<p>Imagine what happens if you have to manage a bunch of computers with different passwords.Its difficult to remember passwords for all of them.For this purpose we have a nice option in ssh called password less login</p>
<p><strong>Password Less login:</strong></p>
<p>To enable password less login you need to have private/public key pair on your local system.Public and private will be in your ~/.ssh/ directory. If not, create a pair using the command</p>
<blockquote><p>ssh-keygen -t rsa</p></blockquote>
<p>Also the ssh server should be configured to allow password less login.Which can be done by uncommenting or adding the following two lines to the configuration file(/etc/ssh/sshd_conf).</p>
<pre>RSAAuthentication yes
PubKeyAuthentication yes</pre>
<p>and then restart the server.</p>
<blockquote><p>/etc/init.d/sshd restart</p></blockquote>
<p>The command will prompt you for a location to save the keys and a pass-phrase.</p>
<pre> Generating public/private rsa key pair.

Enter file in which to save the key (/home/imran/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/imran/.ssh/id_rsa.

Your public key has been saved in /home/imran/.ssh/id_rsa.pub.
</pre>
<p>If we use the default directory, pair of files will be created in ~/.ssh directory.</p>
<p>This comes handy if you are trying to automate something on remote system.</p>
<p>Now we have a key pair. we need to append the contents of the public file .pub file to the remote server&#8217;s authorized keys. This can be done with the following command</p>
<blockquote><p>ssh-copy-id -i ~/.ssh/id_rsa.pub user@my-ssh-server.com</p></blockquote>
<p>This will prompt you for the login password for user. once authenticated it copies the keyfile to ~/.ssh/authorized_keys2 or ~/.ssh/authorized_keys and fixes the permissions if necessary.</p>
<p>That&#8217;s it. you are ready to login without typing password.</p>
<p><strong>Remote command execution:</strong></p>
<p>The thing that i like most in ssh is provision for remote command execution. This feature becomes more powerful when used with password less login</p>
<p>If you want to run a command in my-ssh-server.com, you could use the following command</p>
<blockquote><p>ssh user@my-ssh-server.com &#8216; ps aux | grep sshd &#8216;</p></blockquote>
<p>you can run any command by putting them in quotations(&#8216;command&#8217; )</p>
<p><strong>X11 Forwarding:</strong></p>
<p>X11 forwarding lets you run graphical user interface programs remotely. It forwards the GUI from remote system to your system.But one requirement is ForwardX11 should be enabled in sshd configuration file.</p>
<p>The command to forward X11 is:</p>
<blockquote><p>ssh -X user@my-ssh-server.com</p></blockquote>
<p>then invoke your GUI programs as you will do in local system.</p>
<p><strong>File Transfer (SCP) </strong></p>
<p>How about transferring a file from remote system to remote or vice versa ?</p>
<p>Its simple</p>
<p>from current logged in system to remote system</p>
<blockquote><p>scp file-name1 file-name2 user@my-ssh-server.com:/destination/directory</p></blockquote>
<p>This command will copy files file-name1 and file-name2 to the remote server in /destination/directory.</p>
<p>from remote system to presently logged in system.</p>
<blockquote><p>scp user@my-ssh-server.com:~/file-name1 .</p></blockquote>
<p>This command will copy file file-name1 from user&#8217;s home directory on my-ssh-server.com to the current directory of the user.</p>
<p>You can even copy folders using -r switch of scp</p>
<blockquote><p>scp -r directory-name user@my-ssh-server.com .</p></blockquote>
<p>What if you want to copy from one remoter server to another remoter server ?</p>
<p>its simple</p>
<blockquote><p>scp user@server1.com:~/file user@server2.com:~/file1</p></blockquote>
<p>This command will copy file from server1.com to server2.com</p>
<p><strong>Remote File system mount (SSHFS )</strong></p>
<p>We can even mount the remote file system, a partition on our local system.It can be done with the help of a tool called SSHFS secure shell file System. Of course you need to install it on your system. Once sshfs is installed you can mount remote file system using command</p>
<blockquote><p>sshfs user@my-ssh-server.com:/mnt/media /media/remotedirectory</p></blockquote>
<p>This command will mount /mnt/media from my-ssh-server to your local directory /media/remotedirectory.From now, its like a local file system. you can create, modify and delete files and folders. cool isn&#8217;t it ?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/imranceh.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/imranceh.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/imranceh.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/imranceh.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/imranceh.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/imranceh.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/imranceh.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/imranceh.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/imranceh.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/imranceh.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/imranceh.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/imranceh.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/imranceh.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/imranceh.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=imranceh.wordpress.com&amp;blog=11361731&amp;post=43&amp;subd=imranceh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://imranceh.wordpress.com/2011/05/04/ssh-swiss-army-knife/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a2b6ca6c5befad54f2d95a722d591a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">imranceh</media:title>
		</media:content>
	</item>
		<item>
		<title>Commands to check hardware</title>
		<link>http://imranceh.wordpress.com/2011/04/07/commands-to-check-hardware/</link>
		<comments>http://imranceh.wordpress.com/2011/04/07/commands-to-check-hardware/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 09:17:21 +0000</pubDate>
		<dc:creator>Imran</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://imranceh.wordpress.com/2011/04/07/commands-to-check-hardware/</guid>
		<description><![CDATA[The cool thing about linux is, everything in linux is a file. Hard disk, compact disk, memory, virtually anything is a file. Dig the right files and you will get right info dmidecode gives a detailed list of hardware info ( one awesome command). If you are looking something specific try grep. You can find [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=imranceh.wordpress.com&amp;blog=11361731&amp;post=38&amp;subd=imranceh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The cool thing about linux is, everything in linux is a file. Hard disk, compact disk, memory, virtually anything is a file.</p>
<p>Dig the right files and you will get right info</p>
<p><strong>dmidecode</strong> gives a detailed list of hardware info ( one awesome command). If you are looking something specific try grep.</p>
<p>You can find out your hardware such as:<br />
* IPMI Device<br />
* Type of memory and speed<br />
* Chassis Information<br />
* Temperature Probe<br />
* Cooling Device<br />
* Electrical Current Probe<br />
* Processor and Memory Information<br />
* Serial numbers<br />
* BIOS version<br />
* PCI / PCIe Slots and Speed<br />
* Much more</p>
<p>General syntax is:</p>
<blockquote><p><strong><em>dmidecode &#8211;type {KEYWORD/NUMBER}</em></strong></p></blockquote>
<p>Keyword and numbers can be:</p>
<p>Keyword                       Number</p>
<p>──────────────────────────────</p>
<p>bios                               0, 13</p>
<p>system                      1, 12, 15, 23, 32</p>
<p>baseboard            2, 10, 41</p>
<p>chassis                      3</p>
<p>processor              4</p>
<p>memory                   5, 6, 16, 17</p>
<p>cache                          7</p>
<p>connector              8</p>
<p>slot                                 9</p>
<p><strong>For BIOS info type</strong></p>
<blockquote><p>dmidecode &#8211;type bios</p></blockquote>
<blockquote><p>dmidecode &#8211;type 0</p></blockquote>
<p><strong>For Motherboard info type</strong></p>
<blockquote><p>dmidecode &#8211;type baseboard</p></blockquote>
<p><strong>For processor related info type</strong></p>
<blockquote><p>dmidecode &#8211;type processor</p></blockquote>
<p><strong>For Manufacturer,Model and serial number </strong></p>
<blockquote><p>dmidecode &#8211;type  system</p></blockquote>
<p dir="ltr"><strong>For more info  dig into man page</strong></p>
<p dir="ltr">man dmidecode</p>
<p><strong>Specific commands</strong></p>
<p>0. CPU specifications</p>
<blockquote><p>cat /proc/cpuinfo</p></blockquote>
<p>1. kernel info</p>
<blockquote><p>uname -a</p></blockquote>
<p>kernel version</p>
<blockquote><p>uname -r</p></blockquote>
<p>3. pci cards</p>
<blockquote><p>cat /proc/pci</p></blockquote>
<p>4. Memory(RAM)  and swap information</p>
<blockquote><p>cat /proc/meminfo</p></blockquote>
<blockquote><p>free -m</p></blockquote>
<p>5.Hard drives partitions</p>
<blockquote><p>fdisk -l</p></blockquote>
<p>6. free/used drive space</p>
<blockquote><p>df -h</p></blockquote>
<p>7. Disk usage by current directory and all subdirectories</p>
<blockquote><p>du | less</p></blockquote>
<p>another command is <strong>du -sh /*</strong> to see top level directory wise disk usage</p>
<p>8. dmesg to view the kernel ring buffer (error messages)</p>
<blockquote><p>dmesg | less</p></blockquote>
<blockquote><p>dmesg | egrep ‘(SCSI|scsi0|ide0|hda|sda|serio|mice|eth0|eth1)’</p></blockquote>
<p>9.some other commands</p>
<blockquote><p>lspci ( lists pci device)<br />
lsusb ( lists usb device)</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/imranceh.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/imranceh.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/imranceh.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/imranceh.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/imranceh.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/imranceh.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/imranceh.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/imranceh.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/imranceh.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/imranceh.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/imranceh.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/imranceh.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/imranceh.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/imranceh.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=imranceh.wordpress.com&amp;blog=11361731&amp;post=38&amp;subd=imranceh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://imranceh.wordpress.com/2011/04/07/commands-to-check-hardware/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5a2b6ca6c5befad54f2d95a722d591a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">imranceh</media:title>
		</media:content>
	</item>
	</channel>
</rss>
