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

Python
2022-12-02 18:02 (2 years ago) ytyng

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
Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011