Index: src/github.com/gogs/gogs/models/repo.go
--- src/github.com/gogs/gogs/models/repo.go.orig	2017-02-10 20:16:17.000000000 +0100
+++ src/github.com/gogs/gogs/models/repo.go	2017-02-10 23:27:50.657968000 +0100
@@ -567,9 +567,17 @@
 	repo.Owner = repo.MustOwner()
 	cl := new(CloneLink)
 	if setting.SSH.Port != 22 {
-		cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.SSH.Domain, setting.SSH.Port, repo.Owner.Name, repoName)
+		if setting.SSH.StartBuiltinServer {
+			cl.SSH = fmt.Sprintf("ssh://%s:%d/%s/%s.git", setting.SSH.Domain, setting.SSH.Port, repo.Owner.Name, repoName)
+		} else {
+			cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.SSH.Domain, setting.SSH.Port, repo.Owner.Name, repoName)
+		}
 	} else {
-		cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.SSH.Domain, repo.Owner.Name, repoName)
+		if setting.SSH.StartBuiltinServer {
+			cl.SSH = fmt.Sprintf("ssh://%s/%s/%s.git", setting.SSH.Domain, repo.Owner.Name, repoName)
+		} else {
+			cl.SSH = fmt.Sprintf("ssh://%s@%s/%s/%s.git", setting.RunUser, setting.SSH.Domain, repo.Owner.Name, repoName)
+		}
 	}
 	cl.HTTPS = ComposeHTTPSCloneURL(repo.Owner.Name, repoName)
 	return cl
Index: src/github.com/gogs/gogs/models/ssh_key.go
--- src/github.com/gogs/gogs/models/ssh_key.go.orig	2017-02-10 20:16:17.000000000 +0100
+++ src/github.com/gogs/gogs/models/ssh_key.go	2017-02-10 23:30:52.795096000 +0100
@@ -29,7 +29,7 @@
 )
 
 const (
-	_TPL_PUBLICK_KEY = `command="%s serv key-%d --config='%s'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
+	_TPL_PUBLICK_KEY = `command="%s key-%d --config='%s'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
 )
 
 var sshOpLocker sync.Mutex
@@ -85,7 +85,7 @@
 
 // AuthorizedString returns formatted public key string for authorized_keys file.
 func (k *PublicKey) AuthorizedString() string {
-	return fmt.Sprintf(_TPL_PUBLICK_KEY, setting.AppPath, k.ID, setting.CustomConf, k.Content)
+	return fmt.Sprintf(_TPL_PUBLICK_KEY, "@l_prefix@/sbin/gogs-serv", k.ID, setting.CustomConf, k.Content)
 }
 
 // IsDeployKey returns true if the public key is used as deploy key.
