Category: Techy


My new Tech blog

From now on, all my geeky posts would come up on <\> Solitary Pusuits but other posts will continue on here. So, if you are looking for my newer techy posts, visit the link given. 😀

 

http://anistark.github.io/blog/

 

Advertisements

I’m sure many of you also might be having this problem so I would like to share a hectic experience of setting up my Micromax 3G modem. Now, I have this Micromax 3G modem, and I inserted it in the USB port, but it was not being detected by Ubuntu 12.04. I even tried creating a mobile Internet connection, but still, there is no option to connect. I previously used Ubuntu 11.10, and it had automatically detected the modem and asked me to create a connection. Now I inserted my friend’s Huawei modem and it was detected with no trouble at all. So, I started digging.
On typing lsusb in the terminal it gives the following:

Bus 001 Device 008: ID 1c9e:9605 OMEGA TECHNOLOGY

Amongst many other stuffs. So, detecting modem wasn’t a problem because usb was being detected but the connection wasn’t coming through. The problem as it seems was it had to be registered and Huawei modems are automatically registered. Boy, why don’t they mention the same on the modem box. 😛 Anyways, here’s what I did to get it setup.

On typing lsusb in the terminal, you’ll get the vendor and product ID of your product, which in this case is ID 1c9e:9605
Once you get that, go ahead and do the following to config.

gksudo gedit /etc/usb_modeswitch.d/1c9e:9605

Paste this code on the editor

DefaultVendor = 0x1c9e
DefaultProduct = 0x9605
TargetVendor = 0x1c9e
TargetProduct = 0x9605
MessageContent="55534243123456788000000080000606f50402527000000000000000000000"


Save and exit, then log in as root to your terminal:
su
In case you can’t login as root, add sudo before every commands that follows.
Type & confirm your root password, and do the following:
modprobe usbserial vendor=0x1c9e product=0x9605

usb_modeswitch -c /etc/usb_modeswitch.d/1c9e\:9605

If you didn’t receive any error messages, you’ll then see a new Mobile Broadband Connection on your Network Manager (top right wifi icon)

you need to run this code every session but you can just add the code below to your /etc/rc.local(insert before the ‘exit 0’) so it will be part of your startup programs:

sleep 10
modprobe usbserial vendor=0x1c9e product=0x9605
usb_modeswitch -c /etc/usb_modeswitch.d/1c9e\:9605
sleep 20
nmcli nm wwan on
sleep 10
nmcli con up id "your connection name here"


And that would it all I suppose. That worked for me at least. 😀 Now, some of you might be using some old Micromax modem model which might give lsusb output as 1c9e:9800. Please update to the latest version of usb-modeswitch and you would be good to go. 🙂 For more reading on usb-modeswitch http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?t=692&sid=87157b1cfc5534def6ab31d64ae060b8

 

 

Changing Proxy Settings in Linux

Ubuntu 12.10 will set proxy settings both in /etc/environment and /etc/apt/apt.conf when you set proxy from GUI (Network Settings).

Check your apt settings

grep -Hnri proxy /etc/apt/

will list out the current proxy settings used by apt in the following format.

filename:linenumber:proxy-setting

If you see any output, it corresponds to apt‘s proxy settings. They will have to be cleared.

sudoedit <filename>

will allow you to edit the corresponding configuration file. Copy the existing contents somewhere in case you need to restore them, and delete or comment the lines that look like
Acquire::<protocol>::proxy=<your proxy here>
(Add // at the beginning of a line to comment that line. Commented lines are ignored.)

Save the files, close the text editor, and retry. If the problem persists,

Check global default environment.

grep proxy -i /etc/environment

Should list any proxy settings that are applied globally. If you need to clear them,

sudoedit /etc/environment

will fire up the text editor. Lines that start with # will be ignored, so add a # before those lines that mention your proxy settings. Save the file and retry.

Cleaning the user environment

It is possible that the systemwide configuration is clean but apt is picking up proxy settings from the user’s environment. sudoin certain configurations by default, or when explicitly passed -E as an option, preserves the environment.

env | grep -i proxy

should list out any current environment proxy settings. unset <variable> can be used to unset or clear a variable. Unset all <protocol>_proxy variables. If they are automatically being set, you might comment out the corresponding entries from ~/.profile, ~/.bashrc, ~/.pam_environment

(Those are the most common files that contain the entries. All of them can be searched at once using grep -Hni proxy ~/.profile ~/.bashrc ~/.pam_environment )

 

Ubuntu 12.04

Git Setup

I started using growing interest for Open Source softwares sometime before and then i came across the terms VCS (Version Control System) and eventually my path stopped at GIT. I was glad to see to see github and its uses around.

github image

So i did some basic setup which are in fact not so complicated but there is no single guide that I found online. So, here I decided to provide a single guide based on a number of website references.

The best place to learn is the official doc help from github.com but i got pretty confused for the first time with the whole setup.

If you are new to git and don’t have a clue what it is, you can learn what git from here, http://git-scm.com/book/en/Getting-Started-Git-Basics

Good so now you know what git is and then go ahead and download the latest version of git from here, http://git-scm.com/downloads

Alright, now we are good to go. Open the terminal and start by configuring git.

Username

First you need to tell git your name, so that it can properly label the commits you make.

git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit

Email

Git saves your email address into the commits you make. We use the email address to associate your commits with your GitHub account.

git config --global user.email "your_email@example.com"
# Sets the default email for git to use when you commit

Your email address for Git should be the same one associated with your GitHub account. If it is not, see this guide for help adding additional emails to your GitHub account. If you want to keep your email address hidden, this guide may be useful to you.

Password caching

The last option we need to set will tell git that you don’t want to type your username and password every time you talk to a remote server.

Tip: You need git 1.7.10 or newer to use the credential helper

To use this option, you need to turn on the credential helper so that git will save your password in memory for some time:

git config --global credential.helper cache
# Set git to use the credential memory cache

By default git will cache your password for 15 minutes. You can change this if you like.

git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)

Now git is set and ready for use. Github recommends to use https instead of SSH but i personally feel better using ssh. So, now we are goin to generate some ssh keys for the same use.

Generating SSH Keys

Step 1: Check for SSH keys

First, we need to check for existing ssh keys on your computer. Open up Terminal and run:

cd ~/.ssh
ls
# Lists the files in your .ssh directory

Check the directory listing to see if you have a file named either id_rsa.pub or id_dsa.pub. If you don’t have either of those files go to step 2. Otherwise, you already have an existing keypair, and you can skip to step 3.

Step 2: Generate a new SSH key

To generate a new SSH key, enter the code below. We want the default settings so when asked to enter a file in which to save the key, just press enter.

ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/home/you/.ssh/id_rsa):
ssh-add id_rsa

Now you need to enter a passphrase.

# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]

Which should give you something like this:

# Your identification has been saved in /home/you/.ssh/id_rsa.
# Your public key has been saved in /home/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

Step 3: Add your SSH key to GitHub

Run the following code to copy the key to your clipboard.

sudo apt-get install xclip
# Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)

xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard

Alternatively, using your favorite text editor, you can open the ~/.ssh/id_rsa.pub file and copy the contents of the file manually

  1. Account settings buttonGo to your Account Settings
  2. SSH Keys menuClick “SSH Keys” in the left sidebar
  3. SSH Key buttonClick “Add SSH key”
  4. The key fieldPaste your key into the “Key” field
  5. The Add key buttonClick “Add key”
  6. Confirm the action by entering your GitHub password

Step 4: Test everything out

To make sure everything is working you’ll now SSH to GitHub. When you do this, you will be asked to authenticate this action using your password, which for this purpose is the passphrase you created earlier. Don’t change the git@github.com part. That’s supposed to be there.

ssh -T git@github.com
# Attempts to ssh to github

It’s possible that you’ll see this error message:

...
Agent admitted failure to sign using the key.
debug1: No more authentication methods to try.
Permission denied (publickey).

This is a known problem with certain Linux distributions. For a resolution, see our help article.

You may see this warning:

# The authenticity of host 'github.com (207.97.227.239)' can't be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?

Don’t worry, this is supposed to happen. Verify that the fingerprint matches the one here and type “yes”.

# Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.

If that username is correct, you’ve successfully set up your SSH key. Don’t worry about the shell access thing, you don’t want that anyway.

Now you can use ssh keys 🙂

Lets start by creating your first repository.
Click on create new repository on github.com
Enter the necessary details and it’s done. Now open terminal and type
git clone git@github.com:<username>/<repo_name>
You might be asked to enter your password and the repo has been cloned to your local drive. Next time when you edit something or do some changes, Add to git by,
git add .
git commit -m “<your commit text>”
Sometimes you might get some error like content can not be added by due to some error. Use,
git commit -a
This will clear and then you can probably use pull to pull any changes done to the site and then you can proceed pushing your local changes.
git push origin master
to push your changes to the site.

You can view your changes to the site also. 🙂 That’s more or less everything you need to get the basic stuffs done on git or github 😀

%d bloggers like this: