Categories
blog Linux Ubuntu VMWare

Centos 7.6 Minimal Post Install Change

I’m working on a project at a customer location this week and this particular project required me to install Centos 7+.  Being an Ubuntu guy, I kicked and moaned for about 3 whole seconds and started the install.  It went as smooth as you’d expect, however, I was greeted with no network connectivity once Centos rebooted.  Mentally, I thought it was needing VMWare drivers or something but as it turns out, I just needed to enable the network interface.

vi /etc/sysconfig/network-scripts/ifcfg-<cardname>

Now change ONBOOT=No to ONBOOT=Yes

Then simply reboot and make sure you can get connected to the network.

Categories
blog Linux Ubuntu

bitcoin CPU mining with Ubuntu 12.04

Please do not bother responding with how worthless this is.  This is purely academic.  A few of the guys at my office were curious and I was idle for a little while this weekend and got started with the basics of the basics in bitcon mining.

Prerequisites

Go setup yourself a bitcoin wallet here –> http://www.trybtc.com  There will be some tutorials, feel free to go through those.

You’ll end up here –> https://coinbase.com This is where you can keep track of your account.  First let’s pop in there and grab the bitcoin address that we will use in a bit.  You can find it under Account Settings –> Bitcoin Addresses.  This is how others can give you money.

Create an account here –> https://mining.bitcoin.cz/ This is the only way that CPU mining is even relevant….which it’s really not.  This is a pool of individuals that work on mining bitcoin blocks.

 

Ok, now that you have setup the accounts, here is the basic how-to for setting up CPUMINER on Ubuntu 12.04 Server.  I have this deployed on 16 VM’s running 1 processor and 512 Megs of RAM each for testing.

Install Ubuntu 12.04 Server and get root

wget https://s3.amazonaws.com/clamasters/linked/bcminingprep.sh
chmod o+x bcminingprep.sh

edit bcminingprep.sh for your worker user/pass found under “My Account” in the bitcoin.cz site.

./bcminingprep.sh
./mine.sh

Now you are mining.  Please feel free to comment how fast or slow your mining is going.  I have 16 VM’s on modern hardware under XenServer 6.2 running on AMD processors all getting 4.57 khash/s.  Please note…this is very slow and you will likely never make your money back once power is concerned.

If you want to learn more about bitcoin and bitcoin mining, here are 2 links that I found to be helpful.  http://www.reddit.com/r/bitcoin and http://www.bitcoinmining.com.

Categories
blog Linux

5 Minute Cron Tutorial – Linux Task Scheduler

Cron is an exceptionally useful tool in the Linux world where administrative tasks can easily be rolled up into shell, php, perl, and python scripts among other things. Per a website that I just came across, the word cron comes from the Greek word chronos which means time.

First, lets setup the environment. I use VI as my text editor on Linux and you can view my “60 second VI tutorial” on here as well. To ensure that VI will be our crontab (cron table) editor we will need to edit your “.profile” file for whatever user you are going to be logged in with (typically root).

vi /root/.profile

Add one of thefollowing lines above the second fi to match your preference.

export EDITOR=/usr/bin/vi #if you have just VI installed
export EDITOR=/usr/bin/vim.basic #if you have VIM installed

Ensure that you save it with :wq.

Now that we have that out of the way, lets start scheduling tasks.

Since backups are traditionally something that you would want to automate or schedule, I’ll use it as my main example but first I’ll break down the cron scheduling syntax.

Field Meaning (input)
1 Minutes (0-59)
2 Hours (2-24)
3 Day of the Month (1-31)
4 Month (1-12) January thru December
5 Day of the week (0-6) Sun thru Sat
6 User to execute the command
7 Command to execute

0 2 * * * root tar czf /var/backup/www.tar.gz /var/www >> /dev/null 2>&1

With the above example and the table of what each field does, you get can put together that at 0200 or 2:00 AM every day root will be running “tar czf /var/backup/www.tar.gz /var/www >>/dev/null 2>&1” which is telling tar to tar up /var/www into /var/backup/www.tar.gz and /dev/null 2>&1 is a way to have the command put any output into a “trash can” if you will  Alternately you can specify a log file for that output to go with “>> /var/log/cronforcommand.log 2>&1”.  The * in a schedule means to omit that portion of the schedule.

That one was pretty basic so I’ll get a little more complicated now.  Matter of fact, I’ll just skip the user and command to execute from now on and focus on the command structure for scheduling with cron

EXAMPLES:

Every Minute – * * * * *

Every 5 Minutes – 0,5,10,15,20,25,30,35,40,45,50,66 * * * *

Every 5 Minustes (Simple) – */5 * * * *

Every Hour – * */1 * * *

Every 2 hours – * */2 * * *

Every Day @2:00 AM – 0 2 * * *

Every Day @ 6:00 PM – 0 18 * * *

Every Sunday @ 3:15 AM – 15 3 * * 0

On Feburary 11 @ 10:00 PM – 0 22 11 2 *

That pretty much covers the majority of typical uses for cron. Obviously this is a very powerful tool and can do so much more but for this post, I think it’ll do.  If I messed anything up , please let me know.  🙂 Enjoy.

Categories
blog Linux

Excelent Time Management Video – Randy Pausch

At work, I find it somewhat hard to stay on task.  I like it when I get real material things that can help manage my time.  One of they guys I work with sent me a link for this lecture by Randy Pausch.  As he recently passed due to cancer, this speaks volumes for his character as he had approximately 3 months to live at the time of this talk.  Please enjoy.

Categories
blog Linux Ubuntu

Apache2 on Ubuntu – OpenSSL CSR / Self Signed Cert

Seventy-five percent of the servers I have been working on over the last few months have been Linux.  Mostly Ubuntu.  This due to the fact that my company has allow me to start migrating over and building new servers on this platform.  With that, we need secure ways to access the servers.  On occasion I’ll use webmin but mostly just SSH and whatever website is running on it (management, applications, etc).  Webmin takes care of itself with a self signed certificate and SSH creates its own keys.  Pretty easy there.  Now, for the website that is running on the box, out of the gate it’s unencrypted TCP/80 traffic running from an Apache 2 web server.  This short tutorial will cover how to create a CSR with OpenSSL for use when getting a certificate from one of the CA’s.  I won’t explain everything here but you may use Ubuntu’s https-help guide if you need more info found here.

First, let’s make sure we have the right packages installed.

apt-get install openssh apache2 apache2.2-common php5

Now let’s enable SSL for apache2

sudo a2enmod ssl

Now lets create the server SSL key.

cd /etc/ssl/private
openssl genrsa -des3 -out dns.server.com.key 1024

Ok, now that we have the key, let’s create the CSR to be given to the CA.

openssl req -new -key dns.server.com.key -out dns.server.com.csr

It will prompt you for the passphrase and some other bits of information.  The most important one is site name.  This must match the name of your server.  Something like mail.domain.com or www.domain.com would be appropriate here.

The CSR can now be uploaded to whatever CA you choose.  I use GoDaddy because they are so cheap.

If you do not want to purchase a certificate you can create your own self signed cert with the following command.

openssl x509 -req -days 365 -in dns.server.com.csr -signkey dns.server.com.key -out dns.server.com.crt
cp /etc/ssl/private/dns.server.com.crt /etc/ssl/certs

Now that we have the cert created, let’s configure Apache to use it. Add the following 3 lines to your website configuration.  The default one is located in /etc/apache2/sites-available/default.

SSLEngine on
SSLCertificateFile /etc/ssl/certs/dns.server.com.crt
SSLCertificateKeyFile /etc/ssl/private/dns.server.com.key

Save that config file and enable Apache to listen on 443 for HTTPS traffic.  Add the following line to /etc/apache2/ports.conf

Listen 443

Restart your Apache2 process and you should have a fully functional SSL enabled website.

/etc/init.d/apache2 force-reload && /etc/init.d/apache2/restart