ffdc: Simplify error messages

Tested: Error scenarios
- Missing CLI and env parm cases
- Missing combinations of CLI and env parm cases

Signed-off-by: Peter D  Phan <peterp@us.ibm.com>
Change-Id: I22be1fa0a8c947320c5a1bd4cda672290cfcfcf2
Signed-off-by: Peter D  Phan <peterp@us.ibm.com>
diff --git a/ffdc/ssh_utility.py b/ffdc/ssh_utility.py
index 7957465..37b9314 100644
--- a/ffdc/ssh_utility.py
+++ b/ffdc/ssh_utility.py
@@ -1,9 +1,13 @@
 #!/usr/bin/env python
 
 import paramiko
-from paramiko.ssh_exception import AuthenticationException, NoValidConnectionsError, SSHException
+from paramiko.ssh_exception import AuthenticationException
+from paramiko.ssh_exception import NoValidConnectionsError
+from paramiko.ssh_exception import SSHException
+from paramiko.ssh_exception import BadHostKeyException
 from paramiko.buffered_pipe import PipeTimeout as PipeTimeout
 import scp
+import sys
 import socket
 from socket import timeout as SocketTimeout
 
@@ -19,9 +23,9 @@
         r"""
         Description of argument(s):
 
-        hostname                name/ip of the remote (targeting) host
-        username                user on the remote host with access to FFCD files
-        password                password for user on remote host
+        hostname        Name/IP of the remote (targeting) host
+        username        User on the remote host with access to FFCD files
+        password        Password for user on remote host
         """
 
         self.ssh_output = None
@@ -41,23 +45,18 @@
         try:
             # SSHClient to make connections to the remote server
             self.sshclient = paramiko.SSHClient()
-            # setting set_missing_host_key_policy() to allow any host.
+            # setting set_missing_host_key_policy() to allow any host
             self.sshclient.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+            # pk=paramiko.RSAKey.from_private_key(open('~/.ssh_pub/id_rsa.pub'))
             # Connect to the server
             self.sshclient.connect(hostname=self.hostname,
                                    username=self.username,
                                    password=self.password)
 
-        except AuthenticationException:
-            print("\n>>>>>\tERROR: Authentication failed, please verify your login credentials")
-        except SSHException:
-            print("\n>>>>>\tERROR: Failures in SSH2 protocol negotiation or logic errors.")
-        except NoValidConnectionsError:
-            print('\n>>>>>\tERROR: No Valid SSH Connection after multiple attempts.')
-        except socket.error:
-            print("\n>>>>>\tERROR: SSH Connection refused.")
-        except Exception:
-            raise Exception("\n>>>>>\tERROR: Unexpected Exception.")
+        except (BadHostKeyException, AuthenticationException,
+                SSHException, NoValidConnectionsError, socket.error) as e:
+            print("\n>>>>>\tERROR: Unable to SSH to %s %s %s\n\n" % (self.hostname, e.__class__, e))
+            sys.exit(-1)
 
     def ssh_remoteclient_disconnect(self):
 
@@ -86,8 +85,9 @@
             response = stdout.readlines()
             return response
         except (paramiko.AuthenticationException, paramiko.SSHException,
-                paramiko.ChannelException) as ex:
-            print("\n>>>>>\tERROR: Remote command execution fails.")
+                paramiko.ChannelException) as e:
+            # Log command with error. Return to caller for next command, if any.
+            print("\n>>>>>\tERROR: Fail remote command %s %s %s\n\n" % (command, e.__class__, e))
 
     def scp_connection(self):
 
@@ -111,12 +111,9 @@
 
         try:
             self.scpclient.get(remote_file, local_file)
-        except scp.SCPException:
-            print("scp.SCPException scp %s from remotehost" % remote_file)
-            return False
-        except (SocketTimeout, PipeTimeout) as ex:
-            # Future enhancement: multiple retries on these exceptions due to bad ssh connection
-            print("Timeout scp %s from remotehost" % remote_file)
+        except (scp.SCPException, SocketTimeout, PipeTimeout) as e:
+            # Log command with error. Return to caller for next file, if any.
+            print("\n>>>>>\tERROR: Fail scp %s from remotehost %s %s\n\n" % (remote_file, e.__class__, e))
             return False
 
         # Return True for file accounting