sshkey

package module
v0.0.0-...-1e497ac Latest Latest
Warning

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

Go to latest
Published: May 31, 2015 License: BSD-3-Clause Imports: 17 Imported by: 1

README

golang-sshkey
=============

-----
About
-----
SSH key management utility

-------
Install
-------

.. code:: shell

  $ go get github.com/yosida95/golang-sshkey


--------
Document
--------
https://godoc.org/github.com/yosida95/golang-sshkey

-------
License
-------
golangis licensed under the 3-Clause BSD License. See ./LICENSE.

Documentation

Overview

Example
package main

import (
	"crypto/rsa"
	"fmt"
)

const (
	marshaledPub = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMjH3YZMNFG8cnl98t6w6Ca152cnTsWyrZ56WYSYNkEax1grChZB3P4NcxmtqFxrN2wMXuATiqp62cNkj8wAQUIwRgUnqKkkaQTDyLEDVaTZ75RsZIE4vM/YJ5AzmbCIHK8u6YvfM8fIlv4PKzbMHIIcZvuG9ZYQ+ZEKmSIVxIKZNVfUYyoRK6RFPEMjZPGGoOFRBo8sifsJDLDIBLWOgR4Nf2rWuV+ZuySXX9wjsv42iIdp9RVJcjQXHmi7AKVifKfFJwM+6aPiQcAaWnINzvUnqQK5yrWEp5tVH49bFL92UNriT+LTozloILCj5SdqXQ+JbKp/6EobY96bWhkwyZ yosida95@yosida95"
)

func main() {
	pubkey, err := UnmarshalPublicKey(marshaledPub)
	if err != nil {
		panic(err)
	}
	nativePub := pubkey.Public().(*rsa.PublicKey)

	fmt.Println(pubkey.Type() == KEY_RSA)
	fmt.Println(nativePub.E)
	fmt.Println(pubkey.Length())
	fmt.Println(pubkey.Comment())

}
Output:

true
65537
2048
yosida95@yosida95

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrMalformedKey   = errors.New("Malformed key")
	ErrUnsupportedKey = errors.New("Unsupported key")
)

Functions

func Fingerprint

func Fingerprint(k PublicKey, alg crypto.Hash) ([]byte, error)

func MarshalPublicKey

func MarshalPublicKey(key PublicKey) (result string, err error)

func PrettyFingerprint

func PrettyFingerprint(k PublicKey, alg crypto.Hash) (string, error)

Types

type PublicKey

type PublicKey interface {
	Type() Type
	Public() crypto.PublicKey
	Length() int
	Comment() string
}

func UnmarshalPublicKey

func UnmarshalPublicKey(pub string) (PublicKey, error)

type Type

type Type int
const (
	KEY_RSA Type = iota
	KEY_DSA
	KEY_ECDSA
)

Jump to

Keyboard shortcuts

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