Ejemplo 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()
}
Ejemplo n.º 2
0
	privateKey, err := keys.RSAKeyPairFactory.NewKeyPair(1024)
	Expect(err).NotTo(HaveOccurred())

	payload, err := json.Marshal(map[string]string{
		"host-key":    hostKey.PEMEncodedPrivateKey(),
		"private-key": privateKey.PEMEncodedPrivateKey(),
	})

	Expect(err).NotTo(HaveOccurred())

	return payload

}, func(payload []byte) {
	context := map[string]string{}

	err := json.Unmarshal(payload, &context)
	Expect(err).NotTo(HaveOccurred())

	hostKeyPem := context["host-key"]
	hostKey, err := ssh.ParsePrivateKey([]byte(hostKeyPem))
	Expect(err).NotTo(HaveOccurred())
	TestHostKey = hostKey

	privateKeyPem := context["private-key"]
	privateKey, err := ssh.ParsePrivateKey([]byte(privateKeyPem))
	Expect(err).NotTo(HaveOccurred())
	TestPrivateKey = privateKey

	TestHostKeyFingerprint = helpers.SHA1Fingerprint(TestHostKey.PublicKey())
})