In this post I discuss how to check what program is listening to a port on Ubuntu.
The command to use is
netstat -anp <port number>
The “a” option means that all sockets should be shown, both listening and non-listening ones. The “n” option means numeric. By default netstat translates ports to their service name, making it more difficult to search ports by number. This option solves that. Finally, the “p” option shows the PID and name of the program so that you can tell exactly what’s listening to a port.
When setting up automatic deployment on a software project using git, you may want your server to be able to automatically pull changes from the repository. Popular repo hosts like Github and Bitbucket will usually need your server’s public SSH key to allow access. Assuming you have a server with multiple SSH keys, it may become important for you to specify which SSH key to use for specific users when using git. Here I explain how to make git use a specific private key when accessing Github.
In ~/.ssh/config, add:
host github.com
HostName github.com
IdentityFile <path to id rsa file>
User git
Now you can do git clone git@github.com:username/repo.git.
Make sure the permissions on IdentityFile are 400.
Sources
ssh – How to tell git which private key to use? – Super User. http://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use
Disabling root access via SSH is a good security measure for any public-facing web server. This is because some hackers targeting linux servers know that there’s always a root user and often try to gain access to a server using brute force for that user. So here’s how to disable root login via SSH on ubuntu.
First, make sure there’s at least one other user with sudo privilege. If none exists, create one with the command:
I was part of a group that took part in the World Port Hackathon in Rotterdam from September 4 to 5. The theme of the event was to develop apps or concepts that improve Logistics and Connectivity, Infrastructure or Safety & Security at the port. There were about twenty teams participating in the event and our group Captain Co & Co won the Overall first prize as well as a nomination to participate in Innovation Lab. This article discusses some things I learnt by participating in this event.
You can see my team members with the €1.500 and Nomination Launchlab placards.
First, have a good idea. Our group came up with the idea of making a chat app for port workers. It was an exciting idea. I didn’t know of any other such application on the market and chatting is something we do ubiquitously in the IT world. It was great to introduce such a concept to the shipping industry.
Second, it is important to delegate tasks effectively among team members. There were eight members from my team taking part in the event, four of whom were developers. Among us developers, we split the task of creating the app fairly quickly as the project started. For example two developers developed bots, one took care of the back end server and one handled the front end. The remaining team members handled other aspects like graphics design, testing, idea generation, some programming, getting information from relevant officials at the port concerning data, port processes, etc. and feeding that back to the team.
Third, plan your work carefully. Good communication is essentially when hacking. For example, I remember going away with one of my colleagues to a quiet place to discuss chat APIs, including what format to put data in when communicating between the server and the front end. We did this before starting to code. As such, we both knew how data will flow and could create our parts of the app in parallel, integrating the finished results fairly quickly afterwards. I believe other members had similar plans.
Fourth, you must work hard! Good things come with effort. We put in a good chunk of hours into our app. I remember seeing some other teams looking so relaxed and wondering what kind of apps they were building. As an official at the event later mentioned to us after the event, we looked like a CSI team while we worked. We spent several hours on the project on that Friday and even when the port closed for the night, we went back to our hotel and continued working on the project late into the night. It was rigorous, but fun!
Fifth, do not try to write pretty code. Write it fast and make it work! A hackathon is a hackathon, it’s not a time to write the best looking code. We developers had to create a chat app from scratch that met certain specification, including pulling port-related data, in a relatively short time span. As such on my part I had to write the shortest possible amount of code to get my part of the app working and nothing more. There was no time for fancy things like elaborate frameworks, automated tests, etc. Testing was manual.
Sixth, keep it simple and clean but make sure it works. This is very important in succeeding in a hackathon. Our team had to think carefully of what features we would be able to to our chat app add given the time constraint and available man power. Also, while we produced several interesting features in our app, there were times when we found that a proposed feature didn’t look or work as good as wanted it to. In such situations, we simply left out the feature. So, very important: If you are hacking together an app and one of your features doesn’t look nice, don’t be afraid to remove it. In short, we had to make sure that every feature presented worked. Our chat app was one of the few apps in the entire competition that actually did something; i.e. we could actually chat with it. Many other competitors just presented concepts, diagrams and so on.
Seventh and finally, present your product enthusiastically. We were very cheerful in our presentation of the end product. Our presenter spoke with confidence and all of us team members participated in the presentation by taking part in the chat right there and then.
In conclusion, I had a lovely time taking part in my first hackathon and being on the winning team. I learnt quite a few things about successfully hacking together an app within a short time including the importance of a good idea, delegating tasks effectively, careful planning, putting in your 100%, coding quickly, keeping it simple and effective presentation. Hope you enjoyed the read.
When working in the area of application security, you may come across situations where you need to make sure that only certain servers are allowed to access your web service. Usually checking the ip address is a decent way of making such guarantees.
Note: the add command above may not work if the file name has space in it. A command to use instead may be:
svn st | grep '^?' | sed 's/^[? ]*/"/' | sed 's/$/"/' | xargs svn add
Sources
version control – How do you add all untracked files in svn? Something like git add -i? – Stack Overflow. http://stackoverflow.com/questions/160104/how-do-you-add-all-untracked-files-in-svn-something-like-git-add-i
From time to time, as a web developer you may want to run http load tests against a website to make sure it can handle adequate traffic. An excellent software for this is Siege. So, first, install Siege. On a Mac you can do this using brew as follows:
brew install siege
Once installed, run your test using a command like:
siege -c 10 -r 5 -b http://somesite.com
This runs 5 requests on 10 concurrent connections against somesite.com.
This is just a small tip for the Javascript developers out there. Sometimes you may want to quickly detect when the bottom of a page has been reached. A handy way to do this when using jQuery is to check the following condition:
While having a leisurely swim at the pools a few weeks ago, I came across a girl, Ashley, who swam so well I thought she must be good friends with fishes. So, as we talked a bit, I asked her for some swimming tips. She recommended a few things including the use of nose clips. She explained that when you clip your nose shut, it forces you to concentrate on breathing properly through the mouth while swimming. Also, it prevents water from running up your nose. She told me I could get these from a sports shop.
The next time I swam, I noticed that one of my biggest discomforts was that I sometimes accidentally let in water through my nose, causing fits of coughing. Remembering what Ashley said earlier, I made up my mind right there and then that the next time I visited the pool, it will be with my nose clips. So, I hit Sports Direct and bought a fine nose clip.
A few days later it was time for swimming lessons and I was ready to try out my trusty nose clips. First tip, for those of you with oily noses, you may have a hard time wearing nose clips right away as they may keep slipping off. It’s advisable to first take a swim for a few minutes to get that oil off your nose. Then try on nose clips. Once I had the nose clips on, I noticed that I had to breath in deeper through the mouth to get comfortable. It was amazing to see that even with my nose completely blocked I could breath steadily through the mouth. With this improved depth of breathing, I found that I could cover greater distances during front crawl before needing to face outwards for breath. Furthermore, there was no longer the case of water running up my nose. So, indeed nose clips are a good investment for the neophyte swimmer.
Now, please note, they are good just to help you learn to breath well through the mouth and reduce discomfort of water getting up the nose. Once you learn how to breath sufficiently deeply and properly (blowing bubbles in water for example) and are able to float well, there should be no problems with water getting up your nose and you can safely discard nose clips.