How to install SSH on Linux variants?

In Ubuntu,
$ sudo apt-get install ssh

In Centos, it is
$ yum install ssh

To test if SSH is working, type

$ ssh username@hostname

(First time it will ask if you prefer storing the key values into /home/.ssh/known_hosts so that the server automatically connects at all instances)