package main import ( "io/ioutil" "log" "git.snorba.art/hugo/nssh/storage" ipfsapi "github.com/ipfs/go-ipfs-api" "golang.org/x/crypto/ssh" ) const WebDir = "/hugo-website" func main() { // Public key authentication is done by comparing // the public key of a received connection // with the entries in the authorized_keys file. authorizedKeysBytes, err := ioutil.ReadFile("/home/hugo/.ssh/authorized_keys") if err != nil { log.Fatalf("Failed to load authorized_keys, err: %v", err) } authorizedKeysMap := map[string]bool{} for len(authorizedKeysBytes) > 0 { pubKey, _, _, rest, err := ssh.ParseAuthorizedKey(authorizedKeysBytes) if err != nil { log.Fatal(err) } authorizedKeysMap[string(pubKey.Marshal())] = true authorizedKeysBytes = rest } filestore, err := storage.NewIPFSFilestore(ipfsapi.NewShell("127.0.0.1:5001"), WebDir) if err != nil { log.Fatal(err) } server := &Sshd{ AuthorizedKeysMap: authorizedKeysMap, Filestore: filestore, } log.Fatal(server.Listen("0.0.0.0:2022")) }