diff --git a/vendor/github.com/kardianos/minwinsvc/LICENSE b/modules/minwinsvc/LICENSE
similarity index 100%
rename from vendor/github.com/kardianos/minwinsvc/LICENSE
rename to modules/minwinsvc/LICENSE
diff --git a/vendor/github.com/kardianos/minwinsvc/README.md b/modules/minwinsvc/README.md
similarity index 100%
rename from vendor/github.com/kardianos/minwinsvc/README.md
rename to modules/minwinsvc/README.md
diff --git a/vendor/github.com/kardianos/minwinsvc/minwinsvc.go b/modules/minwinsvc/minwinsvc.go
similarity index 89%
rename from vendor/github.com/kardianos/minwinsvc/minwinsvc.go
rename to modules/minwinsvc/minwinsvc.go
index 057ba7f95..4cd89ffdb 100644
--- a/vendor/github.com/kardianos/minwinsvc/minwinsvc.go
+++ b/modules/minwinsvc/minwinsvc.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a zlib-style
 // license that can be found in the LICENSE file.package service
 
-// Minimal non-invasive windows only service stub.
+// Package minwinsvc is a minimal non-invasive windows only service stub.
 //
 // Import to allow running as a windows service.
 //   import _ "github.com/kardianos/minwinsvc"
diff --git a/vendor/github.com/kardianos/minwinsvc/svc_other.go b/modules/minwinsvc/svc_other.go
similarity index 100%
rename from vendor/github.com/kardianos/minwinsvc/svc_other.go
rename to modules/minwinsvc/svc_other.go
diff --git a/vendor/github.com/kardianos/minwinsvc/svc_windows.go b/modules/minwinsvc/svc_windows.go
similarity index 90%
rename from vendor/github.com/kardianos/minwinsvc/svc_windows.go
rename to modules/minwinsvc/svc_windows.go
index 91e2b6a4d..c6e87e29d 100644
--- a/vendor/github.com/kardianos/minwinsvc/svc_windows.go
+++ b/modules/minwinsvc/svc_windows.go
@@ -8,17 +8,22 @@ package minwinsvc
 
 import (
 	"os"
+	"strconv"
 	"sync"
 
 	"golang.org/x/sys/windows/svc"
 )
 
 var (
-	onExit func()
-	guard  sync.Mutex
+	onExit  func()
+	guard   sync.Mutex
+	skip, _ = strconv.ParseBool(os.Getenv("SKIP_MINWINSVC"))
 )
 
 func init() {
+	if skip {
+		return
+	}
 	interactive, err := svc.IsAnInteractiveSession()
 	if err != nil {
 		panic(err)
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index fd0f5085c..0586bce94 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -22,13 +22,14 @@ import (
 
 	"code.gitea.io/git"
 	"code.gitea.io/gitea/modules/log"
+	_ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
 	"code.gitea.io/gitea/modules/user"
+
 	"github.com/Unknwon/com"
 	_ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
 	_ "github.com/go-macaron/cache/redis"
 	"github.com/go-macaron/session"
 	_ "github.com/go-macaron/session/redis" // redis plugin for store session
-	_ "github.com/kardianos/minwinsvc"      // import minwinsvc for windows services
 	"gopkg.in/ini.v1"
 	"strk.kbt.io/projects/go/libravatar"
 )
diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go
index 056ef084e..18bac8dbf 100644
--- a/modules/ssh/ssh.go
+++ b/modules/ssh/ssh.go
@@ -67,7 +67,11 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
 					args := []string{"serv", "key-" + keyID, "--config=" + setting.CustomConf}
 					log.Trace("SSH: Arguments: %v", args)
 					cmd := exec.Command(setting.AppPath, args...)
-					cmd.Env = append(os.Environ(), "SSH_ORIGINAL_COMMAND="+cmdName)
+					cmd.Env = append(
+						os.Environ(),
+						"SSH_ORIGINAL_COMMAND="+cmdName,
+						"SKIP_MINWINSVC=1",
+					)
 
 					stdout, err := cmd.StdoutPipe()
 					if err != nil {
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 05e01d6e0..a80b8e713 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -514,12 +514,6 @@
 			"revision": "b2c7a7da5b2995941048f60146e67702a292e468",
 			"revisionTime": "2016-02-12T04:00:40Z"
 		},
-		{
-			"checksumSHA1": "/dBJ2h8Jo359deiC5GQ8ZYzX8M8=",
-			"path": "github.com/kardianos/minwinsvc",
-			"revision": "cad6b2b879b0970e4245a20ebf1a81a756e2bb70",
-			"revisionTime": "2015-11-22T16:33:09Z"
-		},
 		{
 			"checksumSHA1": "fh+CcgeUUsnuwSORHYWg0ycbp+4=",
 			"path": "github.com/klauspost/compress/flate",