【Python】scpでリモートサーバー(外部サーバー)のファイルを取得したり削除したりできるクラス
【Python】scpでリモートサーバー(外部サーバー)のファイルを取得したり削除したりできるクラスを作ってみました。
事前に以下のパッケージをインストールする必要があります。
1 | pip install paramiko scp |
SCPClientWrapperクラス
ソースコードは以下の通りです。
SCPClientWrapperクラスの使い方
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | login = { "host": "host", "port": 22, "user": "username", "pass": "password" } with SCPClientWrapper(login) as scp: # リモートサーバーのファイルを取得 spc.get("remote_path", "local_path") # リモートサーバーのファイルを削除 scp.rm("remote_path") # リモートサーバーのファイル一覧を取得 scp.find_file("remote_path") |
コメントを投稿するにはログインが必要です。