パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.0.7

ssh

Flutter用のSSHおよびSFTPクライアント。iOSライブラリNMSSHとAndroidライブラリJSchをラップしています。

30日間ダウンロード
83
いいね数
42
Pub ポイント
35

パッケージをインストール

flutter pub add ssh

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

iOS 用の NMSSH および Android 用の JSch をラップするネイティブライブラリを活用して、SSH および SFTP クライアント機能を提供する Flutter パッケージです。Flutter アプリケーションで安全なリモート接続とファイル転送を可能にし、パスワードまたは鍵による認証をサポートします。クロスプラットフォームのネットワーク操作と安全プロトコルが必要な開発者向けに設計されており、プラットフォーム固有の知識が深くなくても、モバイルアプリに SSH ベースのワークフローを簡単に統合できます。

用途

  • リモートサーバー管理
  • SFTP を通じた安全なファイル転送
  • 自動デプロイスクリプト
  • セキュアなデバイス構成
  • リモートデバッグ
  • システム管理タスク

主な機能

  • クロスプラットフォームのSSH/SFTPサポート
  • パスワードおよびキー基準の認証
  • iOS NMSSH および Android JSch との統合
  • 接続およびファイル操作のためのシンプルな API
  • セキュアな暗号化通信

適している対象

  • 管理者ツールを構築する開発者
  • リモートアクセスを必要とするモバイルアプリ
  • モバイルアプリにおけるCI/CDの統合
  • ネットワークオートメーションプロジェクト
  • セキュアなデータ交換を処理するアプリ

注意事項

  • iOS および Android でネイティブライブラリのセットアップが必要です
  • iOSおよびAndroidプラットフォームに限定
  • 認証資格情報は安全に扱わなければなりません
  • 低性能デバイスでのパフォーマンスのオーバーヘッド
  • SSH セッション用の組み込み UI コンポーネントはありません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

ssh

SSH and SFTP client for Flutter. Wraps iOS library NMSSH and Android library JSch.

Installation

Add ssh as a dependency in your pubspec.yaml file.

Known issue

  • Platform exception in release mode for Android:

    PlatformException(connection_failure, java.lang.ClassNotFoundException: com.jcraft.jsch.jce.Random, null)
    

    There are 2 workarounds:

    • Disable shrink:

      flutter build apk --no-shrink

    • Configure proguard-rules. Refer to this comment for details.

Usage

Create a client using password authentication
import 'package:ssh/ssh.dart';

var client = new SSHClient(
  host: "my.sshtest",
  port: 22,
  username: "sha",
  passwordOrKey: "Password01.",
);
Create a client using public key authentication
import 'package:ssh/ssh.dart';

var client = new SSHClient(
  host: "my.sshtest",
  port: 22,
  username: "sha",
  passwordOrKey: {
    "privateKey": """-----BEGIN RSA PRIVATE KEY-----
    ......
-----END RSA PRIVATE KEY-----""",
    "passphrase": "passphrase-for-key",
  },
);
OpenSSH keys

Recent versions of OpenSSH introduce a proprietary key format that is not supported by most other software, including this one, you must convert it to a PEM-format RSA key using the puttygen tool. On Windows this is a graphical tool. On the Mac, install it per these instructions. On Linux install your distribution's putty or puttygen packages.

  • Temporarily remove the passphrase from the original key (enter blank password as the new password)
    ssh-keygen -p -f id_rsa
  • convert to RSA PEM format
    puttygen id_rsa -O private-openssh -o id_rsa_unencrypted
  • re-apply the passphrase to the original key
    ssh-keygen -p -f id_rsa
  • apply a passphrase to the converted key:
    puttygen id_rsa_unencrypted -P -O private-openssh -o id_rsa_flutter
  • remove the unencrypted version:
    rm id_rsa_unencrypted
Connect client
await client.connect();
Close client
await client.disconnect();
Execute SSH command
var result = await client.execute("ps");
Shell
Start shell:
  • Supported ptyType: vanilla, vt100, vt102, vt220, ansi, xterm
var result = await client.startShell(
  ptyType: "xterm", // defaults to vanilla
  callback: (dynamic res) {
    print(res);     // read from shell
  }
);
Write to shell:
await client.writeToShell("ls\n");
Close shell:
await client.closeShell();
SFTP
Connect SFTP:
await client.connectSFTP();
List directory:
var array = await client.sftpLs("/home"); // defaults to .
Create directory:
await client.sftpMkdir("testdir");
Rename file or directory:
await client.sftpRename(
  oldPath: "testfile",
  newPath: "newtestfile",
);
Remove directory:
await client.sftpRmdir("testdir");
Remove file:
await client.sftpRm("testfile");
Download file:
var filePath = await client.sftpDownload(
  path: "testfile",
  toPath: tempPath,
  callback: (progress) {
    print(progress); // read download progress
  },
);

// Cancel download:
await client.sftpCancelDownload();
Upload file:
await client.sftpUpload(
  path: filePath,
  toPath: ".",
  callback: (progress) {
    print(progress); // read upload progress
  },
);

// Cancel upload:
await client.sftpCancelUpload();
Close SFTP:
await client.disconnectSFTP();

Demo

Refer to the example.

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト