diff --git a/src/Keboola/SSHTunnel/SSH.php b/src/Keboola/SSHTunnel/SSH.php
index <HASH>..<HASH> 100644
--- a/src/Keboola/SSHTunnel/SSH.php
+++ b/src/Keboola/SSHTunnel/SSH.php
@@ -126,7 +126,9 @@ class SSH
         $fileName = (string) tempnam('/tmp/', 'ssh-key-');
 
         file_put_contents($fileName, $key);
-        chmod($fileName, 0600);
+        if (!chmod($fileName, 0600)) {
+            throw new SSHException("Cannot set permissions to SSH private key file.");
+        }
 
         return (string) realpath($fileName);
     }
Check if chmod is successful