All Projects → melbahja → Goph

melbahja / Goph

Licence: mit
🤘 The native golang ssh client to execute your commands over ssh connection. 🚀🚀

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Goph

Wolfssh
wolfSSH is a small, fast, portable SSH implementation, including support for SCP and SFTP.
Stars: ✭ 142 (-80.65%)
Mutual labels:  sftp, ssh, ssh-client
Ssh Mitm
ssh mitm server for security audits supporting public key authentication, session hijacking and file manipulation
Stars: ✭ 335 (-54.36%)
Mutual labels:  sftp, ssh, ssh-client
Lssh
List selection type alternative ssh/scp/sftp client. Pure Go.
Stars: ✭ 110 (-85.01%)
Mutual labels:  sftp, ssh, ssh-client
Sshj
ssh, scp and sftp for java
Stars: ✭ 2,016 (+174.66%)
Mutual labels:  sftp, ssh, ssh-client
Aria
下载可以很简单
Stars: ✭ 4,777 (+550.82%)
Mutual labels:  downloader, sftp, uploader
sshtools
Java SSH tools - easier SSH & SFTP in Java
Stars: ✭ 15 (-97.96%)
Mutual labels:  ssh, sftp, ssh-client
Autossh
Password-free automatic login SSH(免密登陆SSH)
Stars: ✭ 294 (-59.95%)
Mutual labels:  ssh, ssh-client
Ftpgrab
Grab your files periodically from a remote FTP or SFTP server easily
Stars: ✭ 300 (-59.13%)
Mutual labels:  sftp, ssh
Sshoogr
A Groovy-based DSL for working with remote SSH servers.
Stars: ✭ 327 (-55.45%)
Mutual labels:  ssh, ssh-client
Windterm
A quicker and better cross-platform SSH/Sftp/Shell/Telnet/Serial client.
Stars: ✭ 345 (-53%)
Mutual labels:  sftp, ssh
Cowrie
Cowrie SSH/Telnet Honeypot https://cowrie.readthedocs.io
Stars: ✭ 3,810 (+419.07%)
Mutual labels:  sftp, ssh
Bastillion Ec2
A web-based SSH console to execute commands and manage multiple EC2 instances simultaneously running on Amazon Web Services (AWS).
Stars: ✭ 410 (-44.14%)
Mutual labels:  ssh, ssh-client
Sync
syncs your local folder with remote folder using scp
Stars: ✭ 293 (-60.08%)
Mutual labels:  sftp, ssh
Docker Sshd
Minimal Alpine Linux Docker image with sshd exposed and rsync installed
Stars: ✭ 291 (-60.35%)
Mutual labels:  sftp, ssh
Alfred Ssh
Open SSH/SFTP/mosh connections from Alfred 3+
Stars: ✭ 301 (-58.99%)
Mutual labels:  sftp, ssh
Pisth
SSH and SFTP client for iOS
Stars: ✭ 286 (-61.04%)
Mutual labels:  sftp, ssh
Autossh
No password ssh client for Mac/Linux, one key login remote server. 一个SSH远程客户端,可一键登录远程服务器,主要用来弥补Mac/Linux Terminal SSH无法保存密码的不足。
Stars: ✭ 273 (-62.81%)
Mutual labels:  ssh, ssh-client
Phpseclib
PHP Secure Communications Library
Stars: ✭ 4,627 (+530.38%)
Mutual labels:  sftp, ssh
Got
Got: Simple golang package and CLI tool to download large files faster 🏃 than cURL and Wget!
Stars: ✭ 469 (-36.1%)
Mutual labels:  hacktoberfest, downloader
Shellhub
💻 ShellHub enables teams to easily access any Linux device behind firewall and NAT.
Stars: ✭ 686 (-6.54%)
Mutual labels:  hacktoberfest, ssh

Golang SSH Client.

Fast and easy golang ssh client module.

Goph is a lightweight Go SSH client focusing on simplicity!

InstallationFeaturesUsageExamplesLicense

🚀  Installation and Documentation

go get github.com/melbahja/goph

You can find the docs at go docs.

🤘  Features

  • Easy to use and simple API.
  • Supports known hosts by default.
  • Supports connections with passwords.
  • Supports connections with private keys.
  • Supports connections with protected private keys with passphrase.
  • Supports upload files from local to remote.
  • Supports download files from remote to local.
  • Supports connections with ssh agent (Unix systems only).
  • Supports adding new hosts to known_hosts file.
  • Supports file system operations like: Open, Create, Chmod...

📄  Usage

Run a command via ssh:

package main

import (
	"log"
	"fmt"
	"github.com/melbahja/goph"
)

func main() {

	// Start new ssh connection with private key.
	auth, err := goph.Key("/home/mohamed/.ssh/id_rsa", "")
	if err != nil {
		log.Fatal(err)
	}

	client, err := goph.New("root", "192.1.1.3", auth)
	if err != nil {
		log.Fatal(err)
	}

	// Defer closing the network connection.
	defer client.Close()

	// Execute your command.
	out, err := client.Run("ls /tmp/")

	if err != nil {
		log.Fatal(err)
	}

	// Get your output as []byte.
	fmt.Println(string(out))
}

🔐 Start Connection With Protected Private Key:

auth, err := goph.Key("/home/mohamed/.ssh/id_rsa", "you_passphrase_here")
if err != nil {
	// handle error
}

client, err := goph.New("root", "192.1.1.3", auth)

🔑 Start Connection With Password:

client, err := goph.New("root", "192.1.1.3", goph.Password("you_password_here"))

☛ Start Connection With SSH Agent (Unix systems only):

auth, err := goph.UseAgent()
if err != nil {
	// handle error
}

client, err := goph.New("root", "192.1.1.3", auth)

⤴️ Upload Local File to Remote:

err := client.Upload("/path/to/local/file", "/path/to/remote/file")

⤵️ Download Remote File to Local:

err := client.Download("/path/to/remote/file", "/path/to/local/file")

☛ Execute Bash Commands:

out, err := client.Run("bash -c 'printenv'")

☛ Execute Bash Command With Env Variables:

out, err := client.Run(`env MYVAR="MY VALUE" bash -c 'echo $MYVAR;'`)

🥪 Using Goph Cmd:

Goph.Cmd struct is like the Go standard os/exec.Cmd.

// Get new `Goph.Cmd`
cmd, err := client.Command("ls", "-alh", "/tmp")

if err != nil {
	// handle the error!
}

// You can set env vars, but the server must be configured to `AcceptEnv line`.
cmd.Env = []string{"MY_VAR=MYVALUE"}

// Run you command.
err = cmd.Run()

🗒️ Just like os/exec.Cmd you can run CombinedOutput, Output, Start, Wait, and ssh.Session methods like Signal...

📂 File System Operations Via SFTP:

You can easily get a SFTP client from Goph client:


sftp, err := client.NewSftp()

if err != nil {
	// handle the error!
}

file, err := sftp.Create("/tmp/remote_file")

file.Write([]byte(`Hello world`))
file.Close()

🗒️ For more file operations see SFTP Docs.

🥙  Examples

See Examples.

🤝  Missing a Feature?

Feel free to open a new issue, or contact me.

📘  License

Goph is provided under the MIT License.

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].