<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: ssh code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 06 Oct 2008 11:27:07 GMT</pubDate>
    <description>DZone Snippets: ssh code</description>
    <item>
      <title>Compress file in SSH</title>
      <link>http://snippets.dzone.com/posts/show/4686</link>
      <description>The below will compress a file or folder in .tar.gz format in SSH.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;tar -zcvf &lt;new_tar_filename&gt;.tar.gz &lt;filename/directory&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 22 Oct 2007 11:38:10 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4686</guid>
      <author>nothingless (Sasha)</author>
    </item>
    <item>
      <title>Migrate a site to another server</title>
      <link>http://snippets.dzone.com/posts/show/2445</link>
      <description>Use the code below in SSH to migrate all the files of a site from one server to another, without having to download/upload them.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;wget -rc --level=20 ftp://username:password@olddomain.net/public_html&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 20 Aug 2006 00:13:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2445</guid>
      <author>nothingless (Sasha)</author>
    </item>
    <item>
      <title>Migrate a MySQL Database to another server</title>
      <link>http://snippets.dzone.com/posts/show/2444</link>
      <description>Use the below in SSH to move a MySQL database between servers. Super handy if the database is larger than 7MB and you can't use phpMyAdmin.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysqldump -h oldhost -u oldusername -poldpassword olddbname | mysql -h newhost -u newusername -pnewpassword newdbname     &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;http://wiki.dreamhost.com/index.php/Migrate_MySQL</description>
      <pubDate>Sun, 20 Aug 2006 00:11:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2444</guid>
      <author>nothingless (Sasha)</author>
    </item>
    <item>
      <title>Search for terms in Domlogs</title>
      <link>http://snippets.dzone.com/posts/show/1258</link>
      <description>How to search for certain terms in your Domlogs, using SSH.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;for files in /usr/local/apache/domlogs/*; do grep "wget" $files; done;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;-OR-&lt;br /&gt;&lt;br /&gt;&lt;code&gt;cd /usr/local/apache/domlogs&lt;br /&gt;grep wget *&lt;br /&gt;grep lynx *&lt;br /&gt;grep curl *&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Replace wget with other file names/terms you might want to search for.&lt;br /&gt;&lt;br /&gt;If that takes too long, try doing it one by one:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;grep wget a*&lt;br /&gt;grep wget b*&lt;br /&gt;grep wget c*&lt;br /&gt;grep wget d*&lt;br /&gt;grep wget e*&lt;br /&gt;grep wget f*&lt;br /&gt;grep wget g*&lt;br /&gt;grep wget h*&lt;br /&gt;grep wget i*&lt;br /&gt;grep wget j*&lt;br /&gt;grep wget k*&lt;br /&gt;grep wget l*&lt;br /&gt;grep wget m*&lt;br /&gt;grep wget n*&lt;br /&gt;grep wget o*&lt;br /&gt;grep wget p*&lt;br /&gt;grep wget q*&lt;br /&gt;grep wget r*&lt;br /&gt;grep wget s*&lt;br /&gt;grep wget t*&lt;br /&gt;grep wget v*&lt;br /&gt;grep wget w*&lt;br /&gt;grep wget x*&lt;br /&gt;grep wget y*&lt;br /&gt;grep wget z*&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Alternatively, if you get an error like "Argument list too long":&lt;br /&gt;&lt;br /&gt;&lt;code&gt;for i in `ls /usr/local/apache/domlogs|grep -v 'bytes_log'`; do echo "checking on $i" &amp;&amp; grep wget /usr/local/apache/domlogs/$i &amp;&amp; grep lynx /usr/local/apache/domlogs/$i &amp;&amp; grep curl /usr/local/apache/domlogs/$i; done &gt; /root/grep-domlogs-results.txt&lt;/code&gt;&lt;br /&gt;Then simply take a look at this file /root/grep-domlogs-results.txt&lt;br /&gt;</description>
      <pubDate>Sat, 21 Jan 2006 21:42:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1258</guid>
      <author>nothingless (Sasha)</author>
    </item>
    <item>
      <title>Looking up recent dictionary attacks</title>
      <link>http://snippets.dzone.com/posts/show/1254</link>
      <description>Use the code below to look up what words were used in recent dictionary attacks using SSH.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;grep "dictionary attack" /var/log/exim_mainlog&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 21 Jan 2006 21:40:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1254</guid>
      <author>nothingless (Sasha)</author>
    </item>
    <item>
      <title>Looking into DOS and DDOS Attacks</title>
      <link>http://snippets.dzone.com/posts/show/1253</link>
      <description>&lt;a href="http://etechsupport.net/forum/showthread.php?t=434"&gt;A good guide to what to do when your server is attacked&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;top -d2&lt;br /&gt;netstat -nap | grep SYN | wc -l&lt;br /&gt;netstat -nap | less&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If there are many httpd processes showing up after step 1, you might be under attack. If you get high numbers for the second one, you are almost definitely under attack. Use the third one to see the IP addresses, and then ban them from the server:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;iptables -A INPUT -s ip.address -j DROP&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Also try the following for fixing stuff:&lt;br /&gt;&lt;code&gt;cd /dev/shm&lt;br /&gt;ls&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And delete anything that's not supposed to be there.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;locate bindz&lt;br /&gt;locate botnet.txt&lt;br /&gt;locate dc&lt;br /&gt;locate ex0.pl&lt;br /&gt;locate kaiten&lt;br /&gt;locate r0nin&lt;br /&gt;locate udp.pl&lt;br /&gt;locate ...&lt;br /&gt;lsof | grep .,&lt;br /&gt;locate mybot&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 21 Jan 2006 21:39:44 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1253</guid>
      <author>nothingless (Sasha)</author>
    </item>
    <item>
      <title>Ban IPs from a server</title>
      <link>http://snippets.dzone.com/posts/show/1252</link>
      <description>Use the code below to permanently ban an IP address from accessing your server.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;iptables -A INPUT -s ip.address -j DROP&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 21 Jan 2006 21:38:45 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1252</guid>
      <author>nothingless (Sasha)</author>
    </item>
    <item>
      <title>How to tail logs</title>
      <link>http://snippets.dzone.com/posts/show/1251</link>
      <description>&lt;code&gt;&lt;br /&gt;tail -200 /var/log/exim_mainlog&lt;br /&gt;tail -200 /usr/local/apache/logs/error_log&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;To watch the log get updated in real time:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;tail -f /var/log/messages &lt;/code&gt;</description>
      <pubDate>Sat, 21 Jan 2006 21:38:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1251</guid>
      <author>nothingless (Sasha)</author>
    </item>
    <item>
      <title>Sims 2 File Limit Fix</title>
      <link>http://snippets.dzone.com/posts/show/1249</link>
      <description>Type this into Terminal in Mac OSX to fix the file size limit for The Sims 2, allowing you to have more than 5000 downloads.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sudo sysctl -w kern.maxfiles=22000&lt;br /&gt;sudo sysctl -w kern.maxfilesperproc=20000&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 21 Jan 2006 21:37:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1249</guid>
      <author>nothingless (Sasha)</author>
    </item>
    <item>
      <title>How To Manually Update Cpanel</title>
      <link>http://snippets.dzone.com/posts/show/1228</link>
      <description>&lt;code&gt;&lt;br /&gt;/scripts/upcp&lt;br /&gt;&lt;br /&gt;/scripts/upcp --force&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 21 Jan 2006 21:27:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1228</guid>
      <author>nothingless (Sasha)</author>
    </item>
  </channel>
</rss>
