When Using Libraries Like Fabric and Paramiko, "Authentication (publickey) failed." Error Occurs During Server Login
Python
2022-12-02 09:02 (3 years ago)
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):
% head $(which fab)
#!/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:
% /usr/local/opt/python@3.9/bin/python3.9 -m pip install -U paramiko
Related posts
If You Want to Log in Without a Password Using an SSH Key File on a Server, It’s Better Not to Use "Home Directory Encryption"
Fix: pipenv install fails with AttributeError: module 'pkgutil' has no attribute 'ImpImporter' (Python 3.12)
If You Can't Install Python Cryptography, Install Rust with rustup
Logging in via Jump Host with i2cssh
Please rate this article (No signup or login required)
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.