Moving ssh related functions to 'functions.sh' file.

Some refactoring!