So you own an up and running Amazon EC2 instance. And you want it to access via hassle free way. This guided post will describe on how you can do it with few steps.
Note: Just for the convenience I’m referring some steps from this blog here
OK before I start assume you have an up and running EC2 instance. If so grab the public DNS from your AWS management console
It will be probably something like
ec2-#############.compute-1.amazonaws.com
Once that is acquired I again assume you have already made your Key-pair and saved it while you are in the process of creating a new instance
Once that is also in place go to your terminal and CD to the location you saved your Key [your-key-pair.pem] and try to do SSH.
Ok now you have to do is add your self up as a new user and give the root privileges (sudoers). Simply follow execute the following commands on to the AWS terminal
Adding yourself as a user:
$ adduser yourself
granting privileges
$ sudo visudo
find the line root ALL=(ALL:ALL) ALL and the line yourself ALL=(ALL) ALL under it.
Then enable password authentication via (I used the nano editor)
$ sudo nano /etc/ssh/sshd_config
PasswordAuthentication no to PasswordAuthentication yes
Afterward reload the ssh configuration
$ sudo /etc/init.d/ssh reload
OK now logout from the current session and log back as yourself
And to make sure everything is working just fine, execute following
$ sudo -v
You will be promted to enter the password you have provided while creating the user(yourself). Enter that and if everything went well you will get no output on terminal.
Now lets remove this troublesome password authentication replacing SSH RSA public key authentication
To do that first you need to create a SSH RSA public key
So logout from the AWS terminal and from your local terminal execute the following command (Just press return for all the steps)
local-host$ ssh-keygen -t rsa
And you will be promted as below
Now what you have to do is add that key to AWS in order to identify yourself as authorize user.
Finally remove the password authentication and root user access
$ sudo vim /etc/ssh/sshd_config
Find the line PasswordAuthentication yes and change it to PasswordAuthentication no
Also PermitRootLogin yes to PermitRootLogin no
Finally reload the SSH configurations again
$ sudo /etc/init.d/ssh reload
That’s all you need for crating a new user account and allowing authentication via SSH RSA.
If you are still lazy enough to type that long public DNS you can simply assign it to an alias and place it in the ~/.bash_proflle or ~/.bashrc to make it permanent.
amazon cloud ssh
alias connect-amazon='ssh yourself@ec2-#############..compute-1.amazonaws.com'
Assume there’s a situation where you want to generate Java sources from a xml schema definition (xsd). And generate it constantly whenever you want it if the xsd’s got updated.
Solution
There are quiet a few out tools/libs out there but I found this particulate set (Maven and JAXB2) works well for me, just because it’s pretty straight forward. But you may prefer a different approach.
In to the action
Let’s create a very basic maven project (assume you have already set up Maven and Java)
As you may have already know the latest distribution release of OpenSUSE 12.1 ships with Google Go language. Go language was founded by Google as their very own programming language. It works like an interpreter language yet it has to be compiled in order to execute. This small introduction will show you how to set up the environment and run your first Go language program.
Installing Go
Actually Go language is a part of the SUSE 12.1 distribution so you will not get it out of the box that is you have to install it first in order to use it. So lets begin installing Go
sudo zypper install go
Here I have issued the zypper command to install the Go (usual SUSE way of installing packages from repos). It will probably install two packages. Ok after the successful installation lets check if it’s available
whereis go
outputs
go: /usr/lib/go /usr/share/go
Voila.! so we got installed Go
Setting up the environment
As in the Go guided tutorial mentioned we need to set up three environment variables in order to successfully compile and execute a Go program. So lets open up the /.bashrc file where you usually place your environment variables (because /.bashrc file executes with every new session)
sudo nano ~/.bashrc
place three environment variables on the bottom of the file:-
export GOROOT – location of your Go source installation (/usr/lib/go) use whereis command to see that as used before.
export GOOS – Your OS type which is Linux
export GOARCH – Your OS architecture, in my case x86-32 (32-bit) so it goes as 386 [see here for more details]. Issue lscpu to check your sys-architecture.
Ok now everything is setup up. All you have to do now is open a new session, simply logout and re-login. or simply do a source ~/.bashrc
As I did mentioned earlier Go is a compile and run language like C or C++. So you’ll have to to take the necessary steps before you make your Go code to be executed.
Compiling, linking and executing
8g hello.go
8l hello.8
./8.out
Will gives you
hello, world
Note: here I have used 8g, 8l because my arc-type is 32-bit (386).
You will notice a different formation on the guide.
Now you have successfully completed your first Google Go language program. Pretty straight forward hah? To me it seems like that it follows a familiar executing process as in assembly language. So this is just a little heads up you can find more tutorials and code sample on http://golang.org/doc/