| | |
| | | import javax.inject.Singleton; |
| | | |
| | | import org.apache.sshd.SshServer; |
| | | import org.apache.sshd.common.io.IoServiceFactory; |
| | | import org.apache.sshd.common.io.IoServiceFactoryFactory; |
| | | import org.apache.sshd.common.io.mina.MinaServiceFactory; |
| | | import org.apache.sshd.common.io.mina.MinaServiceFactoryFactory; |
| | | import org.apache.sshd.common.io.nio2.Nio2ServiceFactory; |
| | | import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory; |
| | | import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider; |
| | | import org.eclipse.jgit.internal.JGitText; |
| | |
| | | import com.gitblit.transport.ssh.commands.CreateRepository; |
| | | import com.gitblit.transport.ssh.commands.DispatchCommand; |
| | | import com.gitblit.transport.ssh.commands.Receive; |
| | | import com.gitblit.transport.ssh.commands.ReviewCommand; |
| | | import com.gitblit.transport.ssh.commands.SetAccountCommand; |
| | | import com.gitblit.transport.ssh.commands.Upload; |
| | | import com.gitblit.transport.ssh.commands.VersionCommand; |
| | | import com.gitblit.utils.IdGenerator; |
| | |
| | | addr = new InetSocketAddress(bindInterface, port); |
| | | } |
| | | |
| | | SshKeyAuthenticator publickeyAuthenticator = new SshKeyAuthenticator( |
| | | keyManager, gitblit); |
| | | sshd = SshServer.setUpDefaultServer(); |
| | | sshd.setPort(addr.getPort()); |
| | | sshd.setHost(addr.getHostName()); |
| | | sshd.setKeyPairProvider(new PEMGeneratorHostKeyProvider(new File( |
| | | gitblit.getBaseFolder(), HOST_KEY_STORE).getPath())); |
| | | sshd.setPublickeyAuthenticator(new SshKeyAuthenticator(keyManager, gitblit)); |
| | | sshd.setPublickeyAuthenticator(publickeyAuthenticator); |
| | | sshd.setPasswordAuthenticator(new SshPasswordAuthenticator(gitblit)); |
| | | sshd.setSessionFactory(new SshSessionFactory(idGenerator)); |
| | | sshd.setSessionFactory(new SshSessionFactory()); |
| | | sshd.setFileSystemFactory(new DisabledFilesystemFactory()); |
| | | sshd.setTcpipForwardingFilter(new NonForwardingFilter()); |
| | | |
| | | DispatchCommand gitblitCmd = new DispatchCommand(); |
| | | gitblitCmd.registerCommand(CreateRepository.class); |
| | | gitblitCmd.registerCommand(VersionCommand.class); |
| | | gitblitCmd.registerCommand(SetAccountCommand.class); |
| | | gitblitCmd.registerCommand(ReviewCommand.class); |
| | | |
| | | DispatchCommand gitCmd = new DispatchCommand(); |
| | | gitCmd.registerCommand(Upload.class); |
| | |
| | | root.setRepositoryResolver(new RepositoryResolver<SshSession>(gitblit)); |
| | | root.setUploadPackFactory(new GitblitUploadPackFactory<SshSession>(gitblit)); |
| | | root.setReceivePackFactory(new GitblitReceivePackFactory<SshSession>(gitblit)); |
| | | root.setAuthenticator(publickeyAuthenticator); |
| | | |
| | | SshCommandFactory commandFactory = new SshCommandFactory( |
| | | new WorkQueue(idGenerator), |
| | |
| | | sshd.start(); |
| | | run.set(true); |
| | | |
| | | String sshBackendStr = gitblit.getSettings().getString(Keys.git.sshBackend, |
| | | SshSessionBackend.NIO2.name()); |
| | | |
| | | log.info(MessageFormat.format( |
| | | "SSH Daemon is listening on {0}:{1,number,0}", |
| | | sshd.getHost(), sshd.getPort())); |
| | | "SSH Daemon ({0}) is listening on {1}:{2,number,0}", |
| | | sshBackendStr, sshd.getHost(), sshd.getPort())); |
| | | } |
| | | |
| | | /** @return true if this daemon is receiving connections. */ |