diff --git a/var/spack/repos/builtin/packages/libssh/package.py b/var/spack/repos/builtin/packages/libssh/package.py
index c56d545cf322dbbde9dc38f7e56ddb75081ec74d..693b69ec00ed27e78c144db49b12bd490493b0f6 100644
--- a/var/spack/repos/builtin/packages/libssh/package.py
+++ b/var/spack/repos/builtin/packages/libssh/package.py
@@ -15,10 +15,17 @@ class Libssh(CMakePackage):
     version('0.8.5', sha256='07d2c431240fc88f6b06bcb36ae267f9afeedce2e32f6c42f8844b205ab5a335')
     version('0.7.5', sha256='54e86dd5dc20e5367e58f3caab337ce37675f863f80df85b6b1614966a337095')
 
+    variant("gssapi", default=True, description="Build with gssapi support")
     depends_on('openssl@:1.0', when='@:0.7')
     depends_on('openssl')
     depends_on('zlib')
+    depends_on('krb5', when='+gssapi')
 
     def url_for_version(self, version):
         url = "https://www.libssh.org/files/{0}/libssh-{1}.tar.xz"
         return url.format(version.up_to(2), version)
+
+    def cmake_args(self):
+        args = ['-DWITH_GSSAPI=%s' %
+                ('ON' if '+gssapi' in self.spec else 'OFF')]
+        return args