ssh

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright © 2024 Pone Ding <poneding@gmail.com>

Copyright © 2024 Pone Ding <poneding@gmail.com>

Copyright © 2024 Pone Ding <poneding@gmail.com>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddProfile

func AddProfile(profile *Profile)

AddProfile adds a new ssh profile

func Connect

func Connect(profile *Profile)

Connect to the ssh server.

func CreateProfileFile

func CreateProfileFile(file string)

CreateProfileFile creates ssh profile file

func RemoveProfile

func RemoveProfile(profile *Profile)

RemoveProfile removes a profile

func SaveProfiles

func SaveProfiles()

SaveProfiles save the profiles to the profile file

Types

type Options

type Options func(*Profile)

func WithPassword

func WithPassword(password string) Options

func WithPort

func WithPort(port int) Options

func WithPrivateKey

func WithPrivateKey(privateKey string) Options

func WithUser

func WithUser(user string) Options

type Profile

type Profile struct {
	Name       string `json:"name"`
	Host       string `json:"host"`
	Port       int    `json:"port"`
	User       string `json:"user"`
	Password   string `json:"password"`
	PrivateKey string `json:"privateKey"`
	Current    bool   `json:"current"`
}

func FormPrompt

func FormPrompt() *Profile

FormPrompt prompts the user to fill in the ssh profile fields, and returns the new profile.

func GetCurrentProfile

func GetCurrentProfile() *Profile

GetCurrentProfile returns the current profile

func GetProfile

func GetProfile(name string) *Profile

GetProfile returns a profile by name

func GetProfiles

func GetProfiles() []*Profile

GetProfiles returns all the profiles

func NewProfile

func NewProfile(name, host string, options ...Options) *Profile

func SelectPrompt

func SelectPrompt(label PromptLable) (selected *Profile)

SelectPrompt prompts the user to select a ssh profile, and returns the selected profile.

type PromptLable

type PromptLable string
const (
	ConnectPromptLable PromptLable = "Select a ssh profile to connect: "
	RemovePromptLable  PromptLable = "Select a ssh profile to remove: "
)

type PromptOperation

type PromptOperation string
const (
	AddSSHProfilePromptOperation PromptOperation = "+ Add a new ssh profile"
	ExitPromptOperation          PromptOperation = "✗ Exit"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL