Exemplo n.º 1
0
func publicFingerprint(key ssh.Signer) string {
	h := md5.New()
	h.Write(key.PublicKey().Marshal())
	sum := h.Sum(nil)
	var buf bytes.Buffer
	for i, b := range sum {
		bs := fmt.Sprintf("%x", b)
		if len(bs) == 1 {
			buf.WriteRune('0')
		}
		buf.WriteString(bs)
		if i < len(sum)-1 {
			buf.WriteRune(':')
		}
	}
	return buf.String()
}
Exemplo n.º 2
0
import (
	"encoding/json"

	"github.com/cloudfoundry-incubator/diego-ssh/helpers"
	"github.com/cloudfoundry-incubator/diego-ssh/keys"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"golang.org/x/crypto/ssh"

	"testing"
)

var (
	TestHostKey            ssh.Signer
	TestHostKeyFingerprint string
	TestPrivateKey         ssh.Signer
)

func TestCmd(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Cmd Suite")
}

var _ = SynchronizedBeforeSuite(func() []byte {
	hostKey, err := keys.RSAKeyPairFactory.NewKeyPair(1024)
	Expect(err).NotTo(HaveOccurred())

	privateKey, err := keys.RSAKeyPairFactory.NewKeyPair(1024)
	Expect(err).NotTo(HaveOccurred())