Help us shape the future of Go! Take the 2026 Go Developer Survey

credential

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package credential remembers host passwords so that connecting does not mean typing one every time.

Passwords are kept in credentials.json in ~/.ohmyssh, alongside anything else ohmyssh keeps for this user — %USERPROFILE%\.ohmyssh on Windows, which is what os.UserHomeDir reports there. The file is encrypted with AES-256-GCM under a key derived from the local user, machine and OS. Be clear about what that buys: it keeps the passwords out of sight of anything that merely reads the file — a backup, a sync client, a stray `cat` — but the key is derivable by anyone who can already run code as this user, so it is not a defence against a compromised account. The file is written 0600 and the directory 0700, which Windows applies as the read-only attribute and nothing else: there the encryption is the whole of the protection.

A store copied to another machine will not decrypt; the passwords are simply not found and the caller falls back to prompting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear() (int, error)

Clear removes every saved password, reporting how many there were.

func Delete

func Delete(key string) (bool, error)

Delete removes the saved password for key, reporting whether one was there.

func Get

func Get(key string) (string, bool)

Get returns the saved password for key.

func Key

func Key(host config.SSHHost) string

Key names the credential a host needs.

It is the login identity rather than the config alias, so two aliases for the same machine share one saved password, and editing User or Port in the config asks for the new password instead of quietly reusing the old one.

func Keys

func Keys() []string

Keys lists the identities that have a saved password, sorted.

func Path

func Path() string

Path reports where the store lives, for help text and messages.

func Set

func Set(key, password string) error

Set saves password for key, replacing any previous value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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