New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot start builtin SSH server #5435

Closed
YuxuanWang-CHINA opened this Issue Sep 23, 2018 · 15 comments

Comments

3 participants
@YuxuanWang-CHINA
Copy link

YuxuanWang-CHINA commented Sep 23, 2018

  • Gogs version (or commit ref): 0.11.66
  • Git version: 2.18.0
  • Operating system: linux manjaro
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gogs.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist (usually found in log/gogs.log):
    2018/09/23 16:20:54 [TRACE] Log Mode: File (Trace)
    2018/09/23 16:20:54 [ INFO] Gogs 0.11.66.0916
    2018/09/23 16:20:54 [ INFO] Cache Service Enabled
    2018/09/23 16:20:54 [ INFO] Session Service Enabled
    2018/09/23 16:20:54 [ INFO] Git Version: 2.18.0

Description

panic: SSH: Fail to parse private key

goroutine 1 [running]:
github.com/gogs/gogs/pkg/ssh.Listen(0xc000481661, 0x7, 0xbd4, 0xc000080360, 0x6, 0x6)
	/home/wyx/go/src/github.com/gogs/gogs/pkg/ssh/ssh.go:182 +0x3a9
github.com/gogs/gogs/routes.GlobalInit()
	/home/wyx/go/src/github.com/gogs/gogs/routes/install.go:93 +0x233
github.com/gogs/gogs/cmd.runWeb(0xc0003012c0, 0x0, 0xc0003012c0)
	/home/wyx/go/src/github.com/gogs/gogs/cmd/web.go:171 +0x6b
github.com/gogs/gogs/vendor/github.com/urfave/cli.HandleAction(0xe51700, 0xfe8cf8, 0xc0003012c0, 0xc0000b2a00, 0x0)
	/home/wyx/go/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/app.go:483 +0xad
github.com/gogs/gogs/vendor/github.com/urfave/cli.Command.Run(0xf9886d, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfab313, 0x10, 0x0, ...)
	/home/wyx/go/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/command.go:193 +0x98e
github.com/gogs/gogs/vendor/github.com/urfave/cli.(*App).Run(0xc0003349c0, 0xc0000b6000, 0x2, 0x2, 0x0, 0x0)
	/home/wyx/go/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/app.go:250 +0x647
main.main()
	/home/wyx/go/src/github.com/gogs/gogs/gogs.go:40 +0x273

my user:wyx

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Sep 24, 2018

Seems like the actual error message is forgot to print.

Could you try to delete the file /path/to/gogs/ssh/gogs.rsa and restart Gogs see if it works?

@YuxuanWang-CHINA

This comment has been minimized.

Copy link

YuxuanWang-CHINA commented Sep 24, 2018

It does not work.

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Sep 24, 2018

Are you able to find /path/to/gogs/ssh/gogs.rsa this file and delete it, and then see it is recreated?

@YuxuanWang-CHINA

This comment has been minimized.

Copy link

YuxuanWang-CHINA commented Sep 24, 2018

Yes

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Sep 24, 2018

  1. Are you using the binary or build from source code?
  2. What if you roll back to previous version you were using, will it work?
@YuxuanWang-CHINA

This comment has been minimized.

Copy link

YuxuanWang-CHINA commented Sep 24, 2018

Build from source

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Sep 24, 2018

I had two questions, please answer both.

@YuxuanWang-CHINA

This comment has been minimized.

Copy link

YuxuanWang-CHINA commented Sep 24, 2018

I use gogs for the first time.I directly used 'go get' command 2 days ago.

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Sep 24, 2018

I tested on go1.10.4 without problem, I suggest you could also try one of the pre-compiled binary and see if it works: https://github.com/gogs/gogs/releases

If for some reasons it still does not work, then you can turn off (set to false) the built in SSH server:

gogs/conf/app.ini

Lines 26 to 27 in 3a4c981

; Whether use builtin SSH server or not.
START_SSH_SERVER = false

@YuxuanWang-CHINA

This comment has been minimized.

Copy link

YuxuanWang-CHINA commented Sep 24, 2018

I will try. Thanks.

@YuxuanWang-CHINA

This comment has been minimized.

Copy link

YuxuanWang-CHINA commented Sep 24, 2018

@Unknwon
I use binary version

panic: SSH: Fail to parse private key

goroutine 1 [running]:
github.com/gogs/gogs/pkg/ssh.Listen(0xc420039a91, 0x7, 0xc0a, 0xc42009c2a0, 0x6, 0x6)
/home/vagrant/gopath/src/github.com/gogs/gogs/pkg/ssh/ssh.go:182 +0x3ae
github.com/gogs/gogs/routes.GlobalInit()
/home/vagrant/gopath/src/github.com/gogs/gogs/routes/install.go:93 +0x22d
github.com/gogs/gogs/cmd.runWeb(0xc42040d040, 0x0, 0xc42040d040)
/home/vagrant/gopath/src/github.com/gogs/gogs/cmd/web.go:171 +0x6a
github.com/gogs/gogs/vendor/github.com/urfave/cli.HandleAction(0xed81e0, 0x107e108, 0xc42040d040, 0xc42009c700, 0x0)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/app.go:483 +0xad
github.com/gogs/gogs/vendor/github.com/urfave/cli.Command.Run(0x102db1e, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10406af, 0x10, 0x0, ...)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/command.go:193 +0xa35
github.com/gogs/gogs/vendor/github.com/urfave/cli.(*App).Run(0xc42028e4e0, 0xc42000c080, 0x2, 0x2, 0x0, 0x0)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/app.go:250 +0x700
main.main()
/home/vagrant/gopath/src/github.com/gogs/gogs/gogs.go:40 +0x2b8

@YuxuanWang-CHINA

This comment has been minimized.

Copy link

YuxuanWang-CHINA commented Sep 24, 2018

I wonder if START_SSH_SERVER = false , how can i use SSH in git server?

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Sep 24, 2018

Every major Linux distro comes with OpenSSH server daemon suite, or if not, you can install via https://www.tecmint.com/install-openssh-server-in-linux/.

@Unknwon Unknwon changed the title Cannot start ssh server Cannot start builtin SSH server Sep 24, 2018

@mikeperalta1

This comment has been minimized.

Copy link

mikeperalta1 commented Sep 28, 2018

+1 This is happening for me on Fedora 28, but not two other servers running CentOS 7

I have also tried deleting the ssh keys. Same error after they regenerated. ssh-keygen verifies they seem valid.

$ yum list installed | grep -i ssh
libssh.x86_64                               0.8.3-1.fc28                @updates
libssh2.x86_64                              1.8.0-7.fc28                @fedora 
openssh.x86_64                              7.8p1-2.fc28                @updates
openssh-clients.x86_64                      7.8p1-2.fc28                @updates
openssh-server.x86_64                       7.8p1-2.fc28                @updates

$ uname --all
Linux services.azazel 4.18.9-200.fc28.x86_64 #1 SMP Thu Sep 20 02:43:23 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

$ ./gogs -v
Gogs version 0.11.66.0916

$ ./gogs web
2018/09/27 21:41:46 [TRACE] Custom path: /home/gogs/app/custom
2018/09/27 21:41:46 [TRACE] Log path: /home/gogs/log
2018/09/27 21:41:46 [TRACE] Log Mode: Console (Trace)
2018/09/27 21:41:46 [TRACE] Log Mode: File (Trace)
2018/09/27 21:41:46 [ INFO] Azazel Private Gogs 0.11.66.0916
2018/09/27 21:41:46 [ INFO] Cache Service Enabled
2018/09/27 21:41:46 [ INFO] Session Service Enabled
2018/09/27 21:41:46 [ INFO] Mail Service Enabled
2018/09/27 21:41:46 [ INFO] Register Mail Service Enabled
2018/09/27 21:41:46 [ INFO] Notify Mail Service Enabled
2018/09/27 21:41:47 [ INFO] Git Version: 2.17.1
panic: SSH: Fail to parse private key

goroutine 1 [running]:
github.com/gogs/gogs/pkg/ssh.Listen(0xc4203634e1, 0x7, 0xbce, 0xc42016cd20, 0x6, 0x6)
	/home/gogs/go/src/github.com/gogs/gogs/pkg/ssh/ssh.go:182 +0x3ae
github.com/gogs/gogs/routes.GlobalInit()
	/home/gogs/go/src/github.com/gogs/gogs/routes/install.go:93 +0x22d
github.com/gogs/gogs/cmd.runWeb(0xc42031fe00, 0x0, 0xc42031fe00)
	/home/gogs/go/src/github.com/gogs/gogs/cmd/web.go:171 +0x6a
github.com/gogs/gogs/vendor/github.com/urfave/cli.HandleAction(0xe11040, 0xfb26e8, 0xc42031fe00, 0xc42016ca00, 0x0)
	/home/gogs/go/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/app.go:483 +0xad
github.com/gogs/gogs/vendor/github.com/urfave/cli.Command.Run(0xf62bfc, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf75699, 0x10, 0x0, ...)
	/home/gogs/go/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/command.go:193 +0xa35
github.com/gogs/gogs/vendor/github.com/urfave/cli.(*App).Run(0xc420354b60, 0xc4200b2000, 0x2, 0x2, 0x0, 0x0)
	/home/gogs/go/src/github.com/gogs/gogs/vendor/github.com/urfave/cli/app.go:250 +0x700
main.main()
	/home/gogs/go/src/github.com/gogs/gogs/gogs.go:40 +0x2b8

@Unknwon Unknwon added the help wanted label Sep 28, 2018

Unknwon added a commit that referenced this issue Sep 28, 2018

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Dec 13, 2018

Someone has found the solution as follows:

  1. Use ssh-keygen to generate a pair of key in PEM format (be sure to specify another path if your server already has keys in default location!!!):

     ssh-keygen -t rsa -m PEM
    
  2. Replace data/ssh/gogs.rsa and data/ssh/gogs.rsa.pub to private and public keys just generated.

  3. Restart Gogs.

Please try and see if it works.

@Unknwon Unknwon closed this Dec 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment