Move ssh commands into helper function.