---
slug: "python-paramiko-fabric-authentication-publickey-failed"
title: "When Using Libraries Like Fabric and Paramiko, \"Authentication (publickey) failed.\" Error Occurs During Server Login"
description: "When connecting to an SSH server using Python libraries like Fabric or Paramiko, if the versions are outdated, you may encounter the error \"Authentication (publickey) failed.\""
url: "https://www.ytyng.com/en/blog/python-paramiko-fabric-authentication-publickey-failed"
publish_date: "2022-12-02T09:02:19Z"
created: "2022-12-02T09:02:19Z"
updated: "2026-02-26T14:01:48.481Z"
categories: ["Python"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20250602/5e4e82cd53234e898c46c732109bdbb5.png.webp?width=768"
has_video: true
has_music: true
video_urls: ["https://media.ytyng.net/ytyng-blog/265/featured-video-1.mp4", "https://media.ytyng.net/ytyng-blog/265/featured-video-2.mp4", "https://media.ytyng.net/ytyng-blog/265/featured-video-3.mp4"]
music_urls: ["https://media.ytyng.net/ytyng-blog/265/featured-music-265-1.mp3?v=2", "https://media.ytyng.net/ytyng-blog/265/featured-music-265-2.mp3?v=2"]
lang: "en"
---

# When Using Libraries Like Fabric and Paramiko, "Authentication (publickey) failed." Error Occurs During Server Login

When attempting to log in to a server via SSH using tools like Python's fabric or Paramiko, you may encounter an "Authentication (publickey) failed" error on specific servers.

There is an issue on the GitHub repository which has already been addressed:

https://github.com/paramiko/paramiko/issues/1915

This issue occurs when the server is running OpenSSH 8.8 or above and the client is using Paramiko 2.8.0 or below.

To check the Python version used by fabric (fab):

```shell
% head $(which fab)
```

```python
#!/usr/local/opt/python@3.9/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
from fabric.main import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
```

To update the version of Paramiko used by the Python instance for fabric:

```shell
% /usr/local/opt/python@3.9/bin/python3.9 -m pip install -U paramiko
```
