вторник, 19 ноября 2013 г.

Enable SSH private/public key authorization & setting up SSH config file on Linux (Ubuntu)


If you access your SSH remote server with login/password pair and bored by entering password every time you log in (there is no way to save your password in /.ssh/config), consider switching to private/public key authorization instead and setting up the config file, so you'll be able to login like that:

ssh yourhost

Without specifying your host parameters & password every time.

The setup consists from two simple steps: generating a keypair and setting up a config file for SSH.


Generating a keypair


First, you have to generate a key pair using ssh-keygen tool. Like this:
ssh-keygen -t dsa

You'll see the following output:
Generating public/private dsa key pair.

Enter file in which to save the key (/home/yourname/.ssh/id_dsa): hit enter

Enter passphrase (empty for no passphrase): again, hit enter

Enter same passphrase again: hit enter one more time

Your identification has been saved in /home/yourname/.ssh/id_dsa.

Your public key has been saved in /home/yourname/.ssh/id_dsa.pub.


You can also use ssh-keygen -t rsa for better security.
Now you may notice that two new files apper in your ~/.ssh directory: id_dsa & id_dsa.pub

Now you have to copy id_dsa.pub to your remote host. We'll use scp for that

scp ~/.ssh/id_dsa.pub name@host:~/.ssh/

if you need to specify port, use -P option

scp -P <port number goes here> ~/.ssh/id_dsa.pub name@host:~/.ssh/

It will ask for your SSH password, type it and hit enter.

Okay, now your pub key is copied to the remote host.

Now, SSH to the host (it's the last time you going to do that, I promise!):

ssh name@host

Change the name of id_dsa.pub to authorized_keys

mv ~/.ssh/id_dsa.pub ~/.ssh/authorized_keys

Change permissions of the file & folder:

chmod 755 ~/.ssh && chmod 755 ~/.ssh/authorized_keys

Setting up the SSH config file

This step is much simpler.

Just create the ssh config directory  and then the config file with your host parameters:

mkdir ~/.ssh

cd ~/.ssh

touch config
nano config

Then type your remote host details:

Host host1
HostName host1.example.com
User yourname
IdentityFile "~/.ssh/id_dsa"

Save file by pressing Ctrl + X, then hitting Enter

host1 is now the alias for your remote host host1.example.com

To ssh to your host, simply type:

ssh host1

In the terminal, and you will be logged in. Much better now.

воскресенье, 17 ноября 2013 г.

Nate Robins OpenGL tutors on Ubuntu Linux

Nate Robins tutors are great helpers for everybody who wants (or obliged) to learn OpenGL.

The only problem: pre-compiled Linux binaries aren't presented on Nate's website and provided sources doesn't compile in Linux "out of the box".

As it took me some time to figure out how to compile them (I'm quite new to C++), so I'm going to share compilation details here.

All you have to do is to change LDFLAGS string in Makefile from:

LDFLAGS = -lGL -lglu -lglut

To:

LDFLAGS = -lGL -lGLU -lglut -lm

Then, just execute

make

in terminal (don't forget to cd in the directory containing source code), and you're done.

If any errors still appear in the output, try to install the dependencies:

sudo apt-get install freeglut3-dev