After migrating credential.xml & secret* from one jenkins to another..Facing issues of 401 unauthorized

Hi,

I am doing the credentials migration from one jenkins server to another. After the migration of credential.xml and secret*, I am not able to login now.

Attaching the log here…

May 27 15:25:17 env01.successive.work systemd[1]: Started Jenkins Continuous Integration Server.
May 27 15:29:30 env01.successive.work jenkins[2889939]: 2023-05-27 09:59:30.634+0000 [id=15] WARNING h.i.i.InstallUncaughtExceptionHandler#handleException: Caught unhandled exception with ID eae4fe02-ca27-436b-81d1-97b370a9e938
May 27 15:29:30 env01.successive.work jenkins[2889939]: com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized
May 27 15:29:30 env01.successive.work jenkins[2889939]: at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at com.google.api.client.auth.openidconnect.IdTokenResponse.execute(IdTokenResponse.java:120)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.jenkinsci.plugins.googlelogin.GoogleOAuth2SecurityRealm$2.onSuccess(GoogleOAuth2SecurityRealm.java:201)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.jenkinsci.plugins.googlelogin.OAuthSession.doFinishLogin(OAuthSession.java:110)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.jenkinsci.plugins.googlelogin.GoogleOAuth2SecurityRealm.doFinishLogin(GoogleOAuth2SecurityRealm.java:304)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:397)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:409)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:207)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:140)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:558)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:59)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:770)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Stapler.invoke(Stapler.java:900)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:224)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:59)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:770)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Stapler.invoke(Stapler.java:900)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Stapler.invoke(Stapler.java:698)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.Stapler.service(Stapler.java:248)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1665)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:157)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:129)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at jenkins.security.ResourceDomainFilter.doFilter(ResourceDomainFilter.java:81)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at com.atlassian.bitbucket.jenkins.internal.applink.oauth.serviceprovider.auth.OAuth1aRequestFilter.doFilter(OAuth1aRequestFilter.java:91)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationFilter$1.call(ScmSyncConfigurationFilter.java:49)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationFilter$1.call(ScmSyncConfigurationFilter.java:44)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationDataProvider.provideRequestDuring(ScmSyncConfigurationDataProvider.java:106)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationFilter.doFilter(ScmSyncConfigurationFilter.java:44)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:160)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:160)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:94)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at jenkins.security.AcegiSecurityExceptionFilter.doFilter(AcegiSecurityExceptionFilter.java:52)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:99)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:54)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:99)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:126)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:120)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:99)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:100)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:99)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:145)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:101)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:99)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:227)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:221)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:99)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:97)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:99)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:117)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:63)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:99)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:111)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:172)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:53)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:86)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at jenkins.security.SuspiciousRequestFilter.doFilter(SuspiciousRequestFilter.java:38)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:527)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:549)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:223)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1570)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1383)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1543)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1305)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.Server.handle(Server.java:563)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:505)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:416)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:385)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:272)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produce(AdaptiveExecutionStrategy.java:194)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:934)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1078)
May 27 15:29:30 env01.successive.work jenkins[2889939]: at java.base/java.lang.Thread.run(Thread.java:833)

Can anyone help me to revert the change or what I do now!!

Which files exactly did you copy from the old to the new instance?
Did you include all files from the folder secrets?

Hi thanks for the quick response.

From secret folder, I excluded the master.key and org.jenkinsci.main.modules.instance_identity.InstanceIdentity.KEY.

I think you need the master.key as it is used to decrypt credentials

yes, I have tried with master.key also but no success.

Unfortunately, I have revert the changes but now it is saying that 401 unauthorized while login to the server.

You can disable security in the config.xml, but then you need to redo all the security settings

Thanks! I have done the same, now things are working!!