35 lines
621 B
Go
35 lines
621 B
Go
package main
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"log"
|
|
|
|
"go.xsfx.dev/samurai/internal/auth"
|
|
"go.xsfx.dev/samurai/internal/router"
|
|
gossh "golang.org/x/crypto/ssh"
|
|
|
|
"github.com/gliderlabs/ssh"
|
|
)
|
|
|
|
func main() {
|
|
privBytes, err := ioutil.ReadFile("/home/marv/.ssh/id_rsa")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
privKey, err := gossh.ParsePrivateKey(privBytes)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
s := ssh.Server{
|
|
Addr: ":2222",
|
|
HostSigners: []ssh.Signer{privKey},
|
|
PasswordHandler: auth.Auth,
|
|
}
|
|
|
|
ssh.Handle(router.Router)
|
|
log.Println("starting ssh server on port 2222...")
|
|
log.Fatal(s.ListenAndServe())
|
|
}
|