All Projects → jakeheis → Shout

jakeheis / Shout

Licence: mit
SSH made easy in Swift

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Shout

Gossm
💻Interactive CLI tool that you can connect to ec2 using commands same as start-session, ssh in AWS SSM Session Manager
Stars: ✭ 192 (-17.24%)
Mutual labels:  ssh
Ubuntu Sshd
Dockerized Ubuntu SSH service
Stars: ✭ 205 (-11.64%)
Mutual labels:  ssh
Keymaker
Lightweight SSH key management on AWS EC2
Stars: ✭ 221 (-4.74%)
Mutual labels:  ssh
Drawbridge
manage SSH access to multiple applications/environments protected by bastion servers
Stars: ✭ 196 (-15.52%)
Mutual labels:  ssh
Curse
CURSE is an SSH certificate signing server, built as an alternative to Netflix's BLESS tool, but without a dependency on AWS.
Stars: ✭ 200 (-13.79%)
Mutual labels:  ssh
Mac
macOS Mojave v. 10.14 setup for developers.
Stars: ✭ 209 (-9.91%)
Mutual labels:  ssh
Fq Book
📖《这本书能让你连接互联网》详细阐述代理、隧道、VPN运作过程,并对GFW策略如:地址端口封锁、服务器缓存投毒、数字验证攻击、SSL连接阻断做相关的原理说明
Stars: ✭ 2,393 (+931.47%)
Mutual labels:  ssh
Secretive
Store SSH keys in the Secure Enclave
Stars: ✭ 3,228 (+1291.38%)
Mutual labels:  ssh
Browsh
A fully-modern text-based browser, rendering to TTY and browsers
Stars: ✭ 14,058 (+5959.48%)
Mutual labels:  ssh
Opensa
资产管理、资产采集、灰度发布、反向代理、批量任务、任务编排、计划任务、日志审计、权限管理、角色管理、部门管理、运维自动化
Stars: ✭ 220 (-5.17%)
Mutual labels:  ssh
Bundlewrap
Config management with Python
Stars: ✭ 196 (-15.52%)
Mutual labels:  ssh
Secure Wireguard Implementation
A guide on implementing a secure Wireguard server on OVH (or any other Debian VPS) with DNSCrypt, Port Knocking & an SSH-Honeypot
Stars: ✭ 200 (-13.79%)
Mutual labels:  ssh
Cdist
usable configuration management
Stars: ✭ 210 (-9.48%)
Mutual labels:  ssh
Putty Cac
Windows Secure Shell Client With Support For Smart Cards & Certificates
Stars: ✭ 192 (-17.24%)
Mutual labels:  ssh
Hfish
安全、可靠、简单、免费的企业级蜜罐
Stars: ✭ 2,977 (+1183.19%)
Mutual labels:  ssh
Ssh Baseline
DevSec SSH Baseline - InSpec Profile
Stars: ✭ 192 (-17.24%)
Mutual labels:  ssh
Easyssh
The SSH connection manager to make your life easier.
Stars: ✭ 207 (-10.78%)
Mutual labels:  ssh
Chameleon
Customizable honeypots for monitoring network traffic, bots activities and username\password credentials (DNS, HTTP Proxy, HTTP, HTTPS, SSH, POP3, IMAP, STMP, RDP, VNC, SMB, SOCKS5, Redis, TELNET, Postgres and MySQL)
Stars: ✭ 230 (-0.86%)
Mutual labels:  ssh
Manssh
Manage your ssh alias configs easily.
Stars: ✭ 226 (-2.59%)
Mutual labels:  ssh
Brutedum
BruteDum - Brute Force attacks SSH, FTP, Telnet, PostgreSQL, RDP, VNC with Hydra, Medusa and Ncrack
Stars: ✭ 212 (-8.62%)
Mutual labels:  ssh

Shout

Build Status

SSH made easy in Swift

import Shout

let ssh = try SSH(host: "example.com")
try ssh.authenticate(username: "user", privateKey: "~/.ssh/id_rsa")
try ssh.execute("ls -a")
try ssh.execute("pwd")
...

Installation

Ice Package Manager

> ice add jakeheis/Shout

Swift Package Manager

Add Shout as a dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/jakeheis/Shout", from: "0.5.5")
]

Swift 5.2 note

Due to a bug in Swift 5.2, in order to build a project that depends on Shout you must explicitly tell SPM where to find the pkgconfig for libssh2. If you installed libssh2 using Homebrew, the instruction looks something like:

export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
swift build

Generating an Xcode project is done the same way:

export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
swift package generate-xcodeproj

See issue #34 for more details.

Usage

Creating a session

You create a session by passing a host and optionally a port (default 22):

let ssh = try SSH(host: "example.com")
// or
let ssh = try SSH(host: "example.com", port: 22)

Authenticating

You can authenticate with a private key, a password, or an agent.

Private key

To authenticate with a private key, you must pass the username and the path to the private key. You can also pass the path to the public key (defaults to the private key path + ".pub") and the passphrase encrypting the key (defaults to nil for no passphrase)

session.authenticate(username: "user", privateKey: "~/.ssh/id_rsa")
// or
session.authenticate(username: "user", privateKey: "~/.ssh/id_rsa", publicKey: "~/.ssh/id_rsa.pub", passphrase: "passphrase")

Password

Simply pass the username and password:

session.authenticate(username: "user", password: "password")

Agent

If you've already added the necessary private key to ssh-agent, you can authenticate using the agent:

session.authenticateByAgent(username: "user")

Executing commands

You can remotely execute a command one of two ways. session.execute will print the output of the command to stdout and return the status of the command, while session.capture will not print anything to stdout and will return both the status and the output of the command as a string.

let status = try session.execute("ls -a")
let (status, output) = try session.capture("pwd")

Send files

You can send a local file to a remote path, similar to the scp command line program, with sendFile.

let status = try session.sendFile(localURL: myLocalFile, remotePath: "~/cats.png")

SFTP

You can open an SFTP session with the remote server:

let sftp = try session.openSftp()
try sftp.download(remotePath: "/a/remote/file", localURL: myLocalFile)
try sftp.upload(localURL: myLocalFile, remotePath: "~/cats.png")

Configuration

You can instruct the session to request a pty (pseudo terminal) before executing commands:

session.ptyType = .vanilla
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].