Skip to content

Commit

Permalink
Delete dead code.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Jun 17, 2019
1 parent a7fb598 commit abadfed
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions terraform-open-ssh-tunnels/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"encoding/pem"
"fmt"
"io"
"net"
Expand All @@ -15,28 +14,6 @@ import (
"golang.org/x/crypto/ssh/agent"
)

// copied from https://github.com/hashicorp/terraform/blob/7149894e418d06274bc5827c872edd58d887aad9/communicator/ssh/provisioner.go#L213-L232
func readPrivateKey(pk string) (ssh.AuthMethod, error) {
// We parse the private key on our own first so that we can
// show a nicer error if the private key has a password.
block, _ := pem.Decode([]byte(pk))
if block == nil {
return nil, fmt.Errorf("Failed to read key %q: no key found", pk)
}
if block.Headers["Proc-Type"] == "4,ENCRYPTED" {
return nil, fmt.Errorf(
"Failed to read key %q: password protected keys are\n"+
"not supported. Please decrypt the key prior to use.", pk)
}

signer, err := ssh.ParsePrivateKey([]byte(pk))
if err != nil {
return nil, fmt.Errorf("Failed to parse key file %q: %s", pk, err)
}

return ssh.PublicKeys(signer), nil
}

func main() {
if len(os.Args) < 2 {
fmt.Printf("Usage: %s <plan>\n", os.Args[0])
Expand Down

0 comments on commit abadfed

Please sign in to comment.