Compare commits

...

3 commits

Author SHA1 Message Date
Augusto Dwenger J. e11b8d9646 Update crypto lib 2022-03-16 11:47:28 +01:00
Augusto Dwenger J. b4a50e382f Fix variable naming inside the getKey function
This should fix golint.
2022-03-16 11:46:26 +01:00
Augusto Dwenger J. a1a5164061 Unexport PrintData function
There is no need to export the function.
2022-03-16 11:46:26 +01:00
3 changed files with 10 additions and 10 deletions

2
go.mod
View file

@ -4,5 +4,5 @@ go 1.16
require (
github.com/spf13/pflag v1.0.5
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
)

4
go.sum
View file

@ -1,7 +1,7 @@
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

14
main.go
View file

@ -79,7 +79,7 @@ func startAccepting(listener net.Listener, hostKey ssh.Signer) {
if err != nil {
log.Println(err)
}
go PrintData(con, hostKey)
go printData(con, hostKey)
}
}
@ -92,22 +92,22 @@ func getKey(path string) []byte {
return privateBytes
}
privatekey, err := rsa.GenerateKey(rand.Reader, 2048)
privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
log.Fatalf("Cannot generate RSA key\n")
}
privkey_bytes := x509.MarshalPKCS1PrivateKey(privatekey)
privkey_pem := pem.EncodeToMemory(
privateKeyBytes := x509.MarshalPKCS1PrivateKey(privateKey)
privateKeyPem := pem.EncodeToMemory(
&pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: privkey_bytes,
Bytes: privateKeyBytes,
},
)
return privkey_pem
return privateKeyPem
}
func PrintData(con net.Conn, hostKey ssh.Signer) {
func printData(con net.Conn, hostKey ssh.Signer) {
serverConfig := ssh.ServerConfig{PasswordCallback: func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error) {
ip := getIPWithoutPort(conn.RemoteAddr().String())