---
slug: "python-paramiko-fabric-authentication-publickey-failed"
title: "Fabric 等 Paramiko を使うライブラリで、サーバログイン時に Authentication (publickey) failed. が出る場合"
description: "python fabric 等、paramiko を使って SSH サーバに接続する際、バージョンが古いと  Authentication (publickey) failed. エラーが発生します。"
url: "https://www.ytyng.com/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: "ja"
---

# Fabric 等 Paramiko を使うライブラリで、サーバログイン時に Authentication (publickey) failed. が出る場合

Python の fabric 等、 Paramiko を使ってサーバに SSH ログインをしようとすると、特定のサーバで Authentication (publickey) failed. エラーで接続できない場合がある。

Github のレポジトリに Issue があり、既に修正されている。

https://github.com/paramiko/paramiko/issues/1915

サーバが openssh 8.8 以上で、クライアントが paramiko 2.8.0 以下の場合に発生します。


fabric (fab) が使っている Python を調べる

```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())
```

fab が使っている Python の paramiko をアップデートする

```shell
% /usr/local/opt/python@3.9/bin/python3.9 -m pip install -U paramiko
```
