Wednesday, November 6, 2013

SSH from Windows to Linux without a password and without Putty

SSH into Linux from Windows is possible through the Cygwin SSH client, but logging in without a password can be a little tricky. It look me a little trial and error to get it working, so here are my steps:

Open a command prompt and login as root or another user with root privileges.

Create the user, if you haven't already and set the password (I'm using techn, change it to whatever username you want).

useradd techn
passwd techn
Give this user root privileges for now. You can take them away later, if needed.
usermod -G root techn
Create the .ssh directory for techn
mkdir /home/techn/.ssh
Give ownership of the .ssh directory to techn
 chown techn:root .ssh
Assign permissions for this directory to techn
chmod 700 /home/techn/.ssh
Exit the ssh session
exit
From the windows command prompt, run ssh-keygen
ssh-keygen
Choose the defaults, use a password if you want.

Now, the public key (id_rsa.pub) needs to be transferred to the linux server. If you were doing this from linux, you could use the ssh-copy-id script, but this doesn't work from the windows command prompt. So, we use this instead:

cat .ssh/id_rsa.pub | ssh techn@LINUX-HOST "cat >> ~/.ssh/authorized_keys"
It should ask you for techn's password. Supply it and if you receive no error messages, you've succeeded in sending the public key to your linux host. This only works if you have root privileges, sudo doesn't seem to work here. Now you should be able to login without a password:
ssh techn@LINUX-HOST
The following instructions only apply if you want to set up techn with sudo.

On the linux server, install sudo

apt-get install sudo
Log out and log back in as root and remove techn from the root group and put them in the the sudo group
usermod -G sudo techn
Create a text file called 'techn' in your home directory and paste this inside it:
techn ALL=(ALL) ALL
Set the right permissions for this file
chmod 440 techn
Move the file to sudoers.d directory
mv techn /etc/sudoers.d
Do NOT try create this file directly in the sudoers.d directory. You will run in to all kinds of trouble.

Wednesday, October 30, 2013

Simple Master-Slave Replication in MySQL

There's a lot of documentation to set up MySQL replication. The official MySQL documentation goes in to a lot of detail. It took me a while to get it running though. Here's a simple step by step guide for a very simple master-slave setup based on my experience. This was done Ubuntu 12. You might have to tweak the paths and shell commands for other Linux distros.
  1. On both master and slave, allow remote access in /etc/mysql/my.cnf. Set
    bind-address = 0.0.0.0
  2. Configure the slave in my.cnf
    server-id = 30 #unique id
    log-bin = /var/log/mysql/mysql-bin.log
    log-slave-updates
    replicate-same-server-id = 0
    auto_increment_increment = 10
    auto_increment_offset = 2 # unique offset
    report-host = let # slave host name
    
  3. Restart mysql (shell)
    restart mysql
    or (depending on how mysql has been set up)
    service mysql.server restart
  4. Create a slave user on the master (in mysql):
    CREATE USER 'rep_slave'@'SLAVE IP ADDRESS' IDENTIFIED BY 'replication_password';
  5. Allow replication for slave user (in mysql):
    grant replication slave on *.* to 'rep_slave'@'SLAVE IP ADDRESS';
  6. If data needs to be imported from the master, import it using mysqldump

  7. On the Master MySQL get the Log File Name & Log Position (in mysql)
      FLUSH TABLES WITH READ LOCK;
      SHOW MASTER STATUS;
    
  8. On the slave (in mysql)
     CHANGE MASTER TO
       MASTER_HOST='master_host_name/IP address',
       MASTER_USER='rep_slave',
       MASTER_PASSWORD='replication_password',
       MASTER_LOG_FILE='recorded_log_file_name',
       MASTER_LOG_POS=recorded_log_position;
    
    SHOW SLAVE STATUS \G
    
    START SLAVE
    
  9. On the Master (in mysql)
    UNLOCK TABLES
    

Tuesday, May 21, 2013

Pinout for Harman Kardon BT Bluetooth Headphones Charger Cable

I just got this headset and really love it. I'll probably lose the somewhat non-propriety charger cable, which uses a standard USB A connector on one end and a 2.5" 4-pin audio connector jack on the other. So, here's the pin diagram.


Wednesday, March 13, 2013

Google Reader on the execution block


Google has decided to retire Google Reader on July 1st 2013. I can't begin to understand what brought on this decision. Google reader is hugely popular and my favorite RSS feed reader. I'm upset and beginning to wonder if I should wean myself of google's services as they seem to be arbitrarily retiring products without reason.


Time to start hunting for alternatives. You should export your subscriptions from "Reader Settings -> Import/Export".

Update 8pm Central:
There are alternatives - netvibes being the most popular. But, netvibes is very different from Google Reader, and I like Google Reader's way of doing things. I found one that's quite similar to Google Reader at least at first glance. It's not free, it has a 30 day trial and is reasonably priced and has a pay what you want pricing structure starting at $9 a year. Definitely worth it, in my opinion and hopefully shouldn't go away too soon.

bazqux.com






Sunday, January 6, 2013

Anvir Task Manager

There are many task managers out there. I usually use the built-in Windows Task Manager, but when I need something more powerful, the one I use most often is Anvir Task Manager. It comes in 3 flavors: Free, Standard and Pro. The differences are shown here. The free one is quite competent as a Task Manager and is powerful.

There are many bells and whistles that Anvir offers, including startup monitoring. I don't use this feature myself, primarily because I don't leave it running all the time. The distinguishing features that I use are:

1. The ability to kill multiple processes simultaneously. This is very useful if you need to kill viruses, malware or any other rogue processes that have one or more watchdog processes that respawn killed processes. Simply hold Ctrl or Shift while left-clicking on the processes you want to kill and then right-click and left-click "Kill Process".
2. The ability to show open file handles.
3. The ability to show open network connections and associated information.


One thing I really don't like about Anvir, is the almost malware like applications it tries to install during installation. This is a sleazy practice that many freeware developers have started doing. Many people drop such software to show their displeasure of this practice and rightly so. Yes, developers should earn money for their work, but sneaking in unwanted programs, which are annoying and often difficult to remove, really hurts the developer's reputation, especially in the long run.

Add a donate button, you already have premium versions of the program. Yes, most people will not donate, but some will. One thing software developers should learn from the success of the iPhone AppStore and Android's Play Store is that people will buy software without almost thinking if priced right. $50 is something most people will have to think over for a while and most will decide not to buy. Price it at $10 or so, and people can buy without thinking, if it costs them the price of a meal.

To those who've decided to install the program, please read very carefully and click carefully to not install any of the crapware. Anvir Task Manager is a great program, with some bad decisions on the installer.

Anvir Task Manager