網頁

2015年5月19日 星期二

Ubuntu/Lubuntu --- How to securely access Linux VM on Azure or GCE by Remmina

The RSA key is the private encryption key that it can encode/decode sensitive information.

For enhancing security to access cloud server, we will use a public/private key pair on securing SSH channel. That is a public key is placed on cloud server and a private key is located on personal computer. So does that it will deny password-based authentication on SSH access.
How to do it ?

To generate a SSH Key Pair on Windows platform
For creating a SSH Key on Windows platform, we can download the “PuTTY & PuTTY Key Generator” source from PuTTY Download Page  and install these utilities on Windows Platform.
Once the installation completes, we will launch PuTTYgen tool, select the type of key (# 1) and set the number of bits as 1024,2048… bit encryption next to click Generate button for generating a public/private key pair.
擷取選取區域_001.jpg
In the key generation process, we need to move the mouse over the blank area (as yellow area) for making some randomness.
擷取選取區域_003.jpg
When the key generation completes, we may customize the key comment and set the key passphrase for security.
擷取選取區域_004.jpg
Of course, we should save a public/private key on safety location by clicking Save private key and Save public key button.
擷取選取區域_005.jpg


To generate PuTTY key (PPK) on Windows
On Windows Platform with PuTTYGen, we can launch PuTTYGen and click Load button for browing/opening the location of the existing private key file (.ppk extension).
擷取選取區域_010.jpg
If there is the passphrase setting, it will prompt to type in the password.
擷取選取區域_011.jpg
In the menu, we will click the “Conversions” and “Export OpenSSH Key” option next to type/save a filename for the private key.
擷取選取區域_012.jpg
As to the public key, we will directly copy/paste the following content and save as a filename.
擷取選取區域_015.jpg


To convert PuTTY key (PPK) to OPENSSH key (SSH) on Lubuntu
On Lubuntu/Ubuntu, we will use the PuTTY tools for converting key so that it will be installed by using the sudo apt-get install putty-tools command at the terminal prompt. (# 2)
擷取選取區域_016.jpg
Then we will copy a private key pair on /tmp from Windows to Linux and prepare to convert the public key by typing the puttygen privatekeyfilename.ppk -o id_rsa.pub -O public-openssh command at the terminal prompt.
擷取選取區域_018.jpg
To convert private key by typing the puttygen privatekeyfilename.ppk -o id_rsa -O private-openssh command at the terminal prompt.
擷取選取區域_019.jpg


After finish the above convertion, we will move these keys to ~/.ssh and make sure the permissions are set for the private/public key by typing the following command.
mkdir -p ~/.ssh
mv -i ./id_rsa* ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 666 ~/.ssh/id_rsa.pub
擷取選取區域_020.jpg


To convert RSA key(SSH) to PKCS12 certificate(PFX) on Linux
If we only have a RSA key on Linux, we firstly need to generate a PEM certificate by using the openssl req -new -x509 -key id_rsa -out id_rsa.pem command.
擷取選取區域_022.jpg
After fill in the interactive item, we will generate a PFX by using the cat id_rsa id_rsa.pem | openssl pkcs12 -export -out id_rsa.pfx command.
擷取選取區域_023.jpg


To set up the private key on Remmina Remote Desktop Client
Please open Remmina and click New icon for creating a new remote desktop file.
擷取選取區域_030.jpg
In Remote Desktop Preference dialog, we will write down some information as Name, Group, Server, Character set, User name and so on. The connection protocol need to choose “SSH - Secure Shell” due to we will contact Linux platform. As to SSH Authentication, we will choose “Identity file” option because a private/public key pair will be used in the connection
擷取選取區域_031.jpg
In the moment, we will choose a private key from ~/.ssh folder that its source is from convert PuTTY key (PPK) to OPENSSH key (SSH).
擷取選取區域_032.jpg
Finally, click Save button for keeping this Remote Desktop profile.
擷取選取區域_033.jpg


To insert the SSH keys on Google Cloud Engine

To login Google Developers console and choose the project, we will click Compute -> Compute Engine -> VM Instance and choose a specific Instance for inserting the SSH key to the instance-level metadata. (# 3)
擷取選取區域_016.jpg
In SSH Key section, click the Add SSH Keys link
擷取選取區域_009.jpg
and open the public key file and copy/paste the content on the ssh key textbox next to save this change.
擷取選取區域_010.jpg
Please notes the format in the ssh key textbox is “ ” or “ @(# 4)


Once the key is inserted into the instance, we need to reset this VM by clicking Reset button.
擷取選取區域_017.jpg
To wait a moment, we will connect this VM with SSH Keys by Remmina Utility.
擷取選取區域_036.jpg
We have to trust the new public key when we conect to VM at the first time.
擷取選取區域_037.jpg
To key in the passphrase of the private key
擷取選取區域_038.jpg
So do that we will log in the Ubuntu console now.
擷取選取區域_014.jpg


To insert the SSH keys on Microsoft Azure
There is some method to upload/insert SSH key for authentication.
In creating a Linux VM process, we can enable “UPLOAD COMPATIBLE SSH KEY FOR AUTHENTICATION” checkbox and select a certificate file with extension .pem or .cer format.
擷取選取區域_026.jpg


If a public key has already existed on local client, we can add the content of local client’s ~/.ssh/id_rsa.pub to the Azure VM’s ~/.ssh/authorized_keys by using the ssh-copy-id -i ~/.ssh/id_rsa.pub @ -p command.
擷取選取區域_047.jpg


If there is a public key on local client, we will directly copy the id_rsa.pub content from ~/.ssh folder on local client and save as a authorized_keys filename on remote Azure VM.


The related permissions are set for a authorized_keys by typing the following command.
mkdir -p ~/.ssh
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
擷取選取區域_048.jpg


Once the public key is installed on Azure VM and the right permission is set, the SSH access will be granted with no password now.
擷取選取區域_049.jpg

At this point, we should lock this account for password authentication by using the passwd -l command.

擷取選取區域_050.jpg
So does that the key authentication will still be possbile but the password authentication will fail now.
擷取選取區域_051.jpg


Reference:
(# 1)   For Key compatiblity, pleaes select the SSH-1(RSA) type if the private key will want to use on other SSH Client as OpenSSH in the future.
(# 2)   If we ever generate a pubic key by PuTTYGen on Windows platform, we can copy/pase this file to /tmp location on Linux platform next to do the ssh-keygen -i -f /tmp/publickeyfilename > /tmp/id_rsa.pub command.
擷取選取區域_021.jpg
Even we only have a exported private key by PuTTYGen, we still can generate a public key by doing the  ssh-keygen -e -f /tmp/privatekeyfilename > /tmp/id_rsa_com.pub &&  ssh-keygen -i -f /tmp/id_rsa_com.pub > /tmp/id_rsa.pub command
(# 4)   At first, we will connect with SSH into an instance from the browser by selecting Compute -> Compute Engine -> VM Instance -> SSH in the Google Developer Console.
擷取選取區域_003.jpg
By default, a username generated from the email address logged into the account. In the moment, we will change the default username by clicking the Setting icon and select Change Linux Username
擷取選取區域_005.jpg
On Linux system, we will assign a new username that its maximum length will be a 32 character limit.

2015年4月11日 星期六

Eclipse 4.4.2 --- How to install the latest Eclipse on Lubuntu 14.04

If we want to develop Java Language by IDE, the Eclipse will be a good choice because it is a open-source development environment and include the more plugin/extension/solution packages. It also supports various programming languages and can be installed in all Operating systems (Windows , Linux, Mac). So that how to install it?

At first ,we have to download latest eclipse from Eclipse Downloads by choose the right version based on the OS type 32-bit or 64-bit.

Once the file has already been download, we will extract this file by using the sudo tar -zxvf command and move the download packages to /opt directory by using the sudo mv ./eclipse /opt/ command

For creating an Eclipse launcher shortcut, we will create a new file eclipse.desktop in /usr/share/applications (# 2) and add the following content
[Desktop Entry]
Name=Eclipse Luna SR2 (4.4.2)
Type=Application
Exec=/opt/eclipse/eclipse
Terminal=false
Icon=/opt/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;
Name[en]=Eclipse

So do that the entity menu will be added now.


If we want to open eclipse in command mode, we can create a link file using the sudo ln -s /opt/eclipse/eclipse /usr/local/bin/ command to finish it.

Reference :
(# 1)   How to know the OS type installed? we can execute the uname -a | awk '{print $12}'
  command and it will tell us which version depend on the output is x86_64 (64-bit) or i386 (32 bit)

(# 2)   We can create/manage the launchers (*.desktop files) in one of the following directories:
            /usr/share/applications
            /usr/local/share/applications
            ~/.local/share/applications

2015年4月3日 星期五

Ubuntu/Lubuntu --- How to install the latest GNS3 as 1.3.0 from GitHub

We have already installed git on Lubuntu 14.04 x64 by using the sudo apt-get install git command (maybe its version is older) or compiling the source. Once the installation complete, a good suggestion might be to have a folder called git in the home directory which has sub-folders for each of the individual projects. In the moment, the home directory is "My Git" and sub-folder is "source" for locating the download files.

Install GNS3 Server from GitHub
Before the process begin, we have to install the GNS3 Server dependencies as follows by using the sudo apt-get install python3-dev python3-zmq python3-tornado python3-setuptools python3-netifaces command
  • Python 3.3 or above
  • aiohttp
  • setuptools
  • netifaces
  • jsonschema
After the above install, we will get the gns3-server version by visiting the GNS3/gns3-server project's page on GitHub
If we want the latest stable release, we should go change the branch to the latest non-"rc" tag using this button along the left side of the project header

Back on your Lubuntu 14.04, you can type wget and follow it by pasting the address you copied
and download it by using the wget https://github.com/GNS3/gns3-server/archive/v1.3.0.zip -O gns3-server.zip command

Unzip the file that you downloaded and move into the resulting directory by typing unzip gns3-server.zip and cd gns3-server-1.3.0 command

Now, we can install the gns3-server with the dependencies by typing sudo python3 setup.py install command

Install GNS3 GUI from GitHub
Before the process begin, we have to install the GNS3 GUI dependencies as follows by using the sudo apt-get install python3-dev python3-setuptools python3-pyqt4 command
  • Python 3.3 or above
  • Setuptools
  • PyQt libraries
  • Apache Libcloud library
  • Requests library
  • Paramiko library
After the above install, we will get the GNS3-gui version by visiting the GNS3/gns3-gui project's page on GitHub
If we want the latest stable release, we should go change the branch to the latest non-"rc" tag using this button along the left side of the project header

Back on your Lubuntu 14.04, you can type wget and follow it by pasting the address you copied
and download it by using the wget https://github.com/GNS3/gns3-gui/archive/v1.3.0.zip -O gns3-gui.zip command

Unzip the file that we downloaded and move into the resulting directory by typing unzip gns3-gui.zip and cd gns3-gui-1.3.0 command

Now, we can install the gns3-gui with the dependencies by typing sudo python3 setup.py install command

Install Dynampis from GitHub
Before the process begin, we have to install the Dynampis dependencies as follows by using the sudo apt-get install libelf-dev uuid-dev libpcap0.8-dev cmake command
  • libelf-dev
  • uuid-dev
  • libpcap0.8-dev
After the above install, we will get the Dynampis version by visiting the GNS3/dynamips project's page on GitHub
If we want the latest stable release, we should go change the branch to the latest non-"rc" tag using this button along the left side of the project header

Back on your Lubuntu 14.04, you can type wget and follow it by pasting the address you copied
and download it by using the wget https://github.com/GNS3/dynamips/archive/v0.2.14.zip -O dynampis.zip command

Unzip the file that we downloaded and move into the resulting directory by typing unzip dynampis.zip and cd dynampis-0.2.14 command

Due to Dynamips now uses the CMake build system, we have to generate the Makefiles required for compiling Dynamips by typing mkdir build and cd build and cmake .. command

Now, we can build and install Dynamips by typing make prefix=/usr/local all and sudo make prefix=/usr/local install command
Finally, provide network support for IOU by typing the sudo setcap cap_net_admin,cap_net_raw=ep /usr/local/bin/dynamips command

Install IOUYAP from GitHub
Before the process begin, we have to install the IOU dependencies as follows
$ sudo apt-get install libssl1.0.0:i386
$ sudo ln -s /lib/i386-linux-gnu/libcrypto.so.1.0.0 /lib/libcrypto.so.4
$ sudo apt-get install gcc flex bison git

$ git clone http://github.com/ndevilla/iniparser.git
$ cd iniparser
$ sudo make

$ sudo cp libiniparser.* /usr/lib/
$ sudo cp src/iniparser.h /usr/local/include
$ sudo cp src/dictionary.h /usr/local/include

After the above install, we will get the IOUYAP version by visiting the GNS3/iouyap project's page on GitHub
and only choose the non-"rc" tag using this button along the left side of the project header

Back on your Lubuntu 14.04, you can type wget and follow it by pasting the address you copied
and download it by using the wget https://github.com/GNS3/iouyap/archive/0.95.zip -O iouyap.zip command

Unzip the file that we downloaded and move into the resulting directory by typing unzip iouyap.zip and cd iouyap-0.95 command

Due to IOUYAP Makefiles exist, we can directly install IOUYAP by typing sudo make prefix=/usr/local install command

Finally, copy it to /usr/local/bin by using the sudo cp iouyap /usr/local/bin command and then provide network support for IOU by typing the sudo setcap cap_net_admin,cap_net_raw=ep /usr/local/bin/iouyap command.

Install VPCS from GitHub (# 1)
For virtual PC connections to the Routers and switches, we need to install Simple Virtual PC Simulator.
At first, we will get the VPCS version by visiting the GNS3/vpcs project's page on GitHub
and only choose the non-"rc" tag using this button along the left side of the project header
Back on your Lubuntu 14.04, you can type wget and follow it by pasting the address you copied
and download it by using the wget https://github.com/GNS3/vpcs/archive/v0.5b1.zip -O vpcs.zip command

Unzip the file that we downloaded and move into the resulting directory by typing unzip vpcs.zip and cd vpcs-0.5b1/src command

We can directly compile VPCS by typing ./mk.sh command and copy it to /usr/local/bin by using the sudo cp vpcs /usr/local/bin command


Until now, we have successfully installed GNS3 1.3.0 and run it by typing the gns3 command.

In the future, how to upgrade to a new version? example for gns3-gui
To find the URL to use for the clone operation, navigate to the branch or tag that we want on the project's GitHub page and then copy the clone URL on the right side
Next we can simply clone the repository by using the git clone https://github.com/GNS3/gns3-gui.git command so that will create a new directory within your current directory.

As to the next step, please follow the above installation procedure based on each function.
So does that will overwrite your older version with the new version now.

Reference:
(# 1)   Due to it will not be updated version in GitHub, we can download/Install the latest VPCS from http://sourceforge.net/projects/vpcs/files/

Since 2010 Design by Davidwa
©Copyright Davidwa Inc. All rights reserved.