diff --git a/templates/wg.conf b/templates/wg.conf
index 5ac207b..745a92f 100644
--- a/templates/wg.conf
+++ b/templates/wg.conf
@@ -19,6 +19,6 @@ PostDown = {{ .serverConfig.Interface.PostDown }}
 # Update at:    {{ .Client.UpdatedAt }}
 [Peer]
 PublicKey = {{ .Client.PublicKey }}
-PresharedKey = {{ .Client.PresharedKey }}
-AllowedIPs = {{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{range .Client.ExtraAllowedIPs }},{{.}}{{end}}
+{{if .Client.PresharedKey }}PresharedKey = {{ .Client.PresharedKey }}
+{{end}}AllowedIPs = {{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{range .Client.ExtraAllowedIPs }},{{.}}{{end}}
 {{end}}{{end}}
diff --git a/util/util.go b/util/util.go
index 7622918..7c347a9 100644
--- a/util/util.go
+++ b/util/util.go
@@ -21,17 +21,21 @@ import (
 // BuildClientConfig to create wireguard client config string
 func BuildClientConfig(client model.Client, server model.Server, setting model.GlobalSetting) string {
 	// Interface section
-	clientAddress := fmt.Sprintf("Address = %s", strings.Join(client.AllocatedIPs, ","))
-	clientPrivateKey := fmt.Sprintf("PrivateKey = %s", client.PrivateKey)
+	clientAddress := fmt.Sprintf("Address = %s\n", strings.Join(client.AllocatedIPs, ","))
+	clientPrivateKey := fmt.Sprintf("PrivateKey = %s\n", client.PrivateKey)
 	clientDNS := ""
 	if client.UseServerDNS {
-		clientDNS = fmt.Sprintf("DNS = %s", strings.Join(setting.DNSServers, ","))
+		clientDNS = fmt.Sprintf("DNS = %s\n", strings.Join(setting.DNSServers, ","))
 	}
 
 	// Peer section
-	peerPublicKey := fmt.Sprintf("PublicKey = %s", server.KeyPair.PublicKey)
-	peerPresharedKey := fmt.Sprintf("PresharedKey = %s", client.PresharedKey)
-	peerAllowedIPs := fmt.Sprintf("AllowedIPs = %s", strings.Join(client.AllowedIPs, ","))
+	peerPublicKey := fmt.Sprintf("PublicKey = %s\n", server.KeyPair.PublicKey)
+	peerPresharedKey := ""
+	if client.PresharedKey != "" {
+		peerPresharedKey = fmt.Sprintf("PresharedKey = %s\n", client.PresharedKey)
+	}
+
+	peerAllowedIPs := fmt.Sprintf("AllowedIPs = %s\n", strings.Join(client.AllowedIPs, ","))
 
 	desiredHost := setting.EndpointAddress
 	desiredPort := server.Interface.ListenPort
@@ -44,24 +48,24 @@ func BuildClientConfig(client model.Client, server model.Server, setting model.G
 			log.Error("Endpoint appears to be incorrectly formatted: ", err)
 		}
 	}
-	peerEndpoint := fmt.Sprintf("Endpoint = %s:%d", desiredHost, desiredPort)
+	peerEndpoint := fmt.Sprintf("Endpoint = %s:%d\n", desiredHost, desiredPort)
 
 	peerPersistentKeepalive := ""
 	if setting.PersistentKeepalive > 0 {
-		peerPersistentKeepalive = fmt.Sprintf("PersistentKeepalive = %d", setting.PersistentKeepalive)
+		peerPersistentKeepalive = fmt.Sprintf("PersistentKeepalive = %d\n", setting.PersistentKeepalive)
 	}
 
 	// build the config as string
 	strConfig := "[Interface]\n" +
-		clientAddress + "\n" +
-		clientPrivateKey + "\n" +
-		clientDNS + "\n\n" +
-		"[Peer]" + "\n" +
-		peerPublicKey + "\n" +
-		peerPresharedKey + "\n" +
-		peerAllowedIPs + "\n" +
-		peerEndpoint + "\n" +
-		peerPersistentKeepalive + "\n"
+		clientAddress +
+		clientPrivateKey +
+		clientDNS +
+		"\n[Peer]\n" +
+		peerPublicKey +
+		peerPresharedKey +
+		peerAllowedIPs +
+		peerEndpoint +
+		peerPersistentKeepalive
 
 	return strConfig
 }