diff --git a/Lib/crypt.py b/Lib/crypt.py
index 33dbc46bb3e96bed9f32f7919c81cfda069b65ce..b296c3edb0f511e11b442b7f1dc9cd8b670c7c33 100644
--- a/Lib/crypt.py
+++ b/Lib/crypt.py
@@ -94,7 +94,7 @@ def _add_method(name, *args, rounds=None):
         result = crypt('', salt)
     except OSError as e:
         # Not all libc libraries support all encryption methods.
-        if e.errno == errno.EINVAL:
+        if e.errno in {errno.EINVAL, errno.EPERM, errno.ENOSYS}:
             return False
         raise
     if result and len(result) == method.total_size:
diff --git a/Misc/NEWS.d/next/Library/2022-07-25-15-45-06.gh-issue-95231.i807-g.rst b/Misc/NEWS.d/next/Library/2022-07-25-15-45-06.gh-issue-95231.i807-g.rst
new file mode 100644
index 0000000000000000000000000000000000000000..aa53f2938bc930ebe70df36da7eb5c22a84c1bb7
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-07-25-15-45-06.gh-issue-95231.i807-g.rst
@@ -0,0 +1,3 @@
+Fail gracefully if :data:`~errno.EPERM` or :data:`~errno.ENOSYS` is raised when loading
+:mod:`crypt` methods. This may happen when trying to load ``MD5`` on a Linux kernel
+with :abbr:`FIPS (Federal Information Processing Standard)` enabled.