패키지, 저장소 및 앱 카테고리 검색

패키지 상세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 클라이언트 기능을 제공하는 플러터 패키지입니다. 안전한 원격 연결과 파일 전송을 가능하게 하며, 비밀번호 또는 키를 통한 인증을 지원합니다. 크로스플랫폼 네트워크 작업과 보안 프로토콜이 필요한 개발자를 위해 설계되었으며, 플랫폼별 깊은 지식 없이도 모바일 앱에 SSH 기반 워크플로우를 간편하게 통합할 수 있습니다.

사용 사례

  • 원격 서버 관리
  • SFTP를 통한 안전한 파일 전송
  • 자동화된 배포 스크립트
  • 보안 장치 구성
  • 원격 디버깅
  • 시스템 관리 작업

주요 기능

  • 크로스플랫폼 SSH/SFTP 지원
  • 암호 및 키 기반 인증
  • iOS NMSSH 및 Android JSch와의 통합
  • 연결 및 파일 작업을 위한 간단한 API
  • 안전한 암호화 통신

적합한 대상

  • 관리 도구를 구축하는 개발자
  • 원격 액세스가 필요한 모바일 앱
  • 모바일 앱에서의 CI/CD 통합
  • 네트워크 자동화 프로젝트
  • 보안 데이터 교환을 처리하는 앱

고려 사항

  • iOS 및 안드로이드에서 네이티브 라이브러리 설정이 필요합니다
  • 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 개

소스 저장소

이 패키지를 사용하는 프로젝트