ixrjog / opscloud4

云上运维
Apache License 2.0
1.33k stars 509 forks source link

工作台的ssh 无法登陆主机 #61

Closed unixtommy closed 2 years ago

unixtommy commented 2 years ago
QQ20220331-164522@2x

我尝试了 私钥和密码都不行,绑定私钥的话,就会报下面的错误: -----END RSA PRIVATE KEY----- (No such file or directory) at com.jcraft.jsch.KeyPair.load(KeyPair.java:557) at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:40) at com.jcraft.jsch.JSch.addIdentity(JSch.java:494) at com.baiyi.opscloud.sshcore.handler.RemoteInvokeHandler.invokeSshCredential(RemoteInvokeHandler.java:59) at com.baiyi.opscloud.sshcore.handler.RemoteInvokeHandler.openWebTerminal(RemoteInvokeHandler.java:84) at com.baiyi.opscloud.terminal.processor.impl.LoginProcessor.lambda$process$0(LoginProcessor.java:49) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.FileNotFoundException: -----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAvt9ykN1dNEIjAAbjuO0dRRdpJt4HP7XAODyih9HQ6pUGqkHd s+kO5TTy2nSXWDqkglWQcszp2mgNTNsRb+hJMBmIPnswKiH31Z3KhWoyNC8qmGMI lvVFwSpLgjmYazm+uu+l/pD3MGomkdsm3fuKR2Zt9El9UamqM7yq7Xl5sN+B7rfL MucLzxtbI/JTnUsunSeVQQCwdbP0fi2anuvlPRA1tvJDHnVubTH4840JfFEKZGCY WJhBFXXIfnabCjh7d9oHDj/fxbS0nEIX0njdZxIVOjPjphA6ULmlsmWBk0zz9hUk VJciOBwu7C4lT3II9CT2QV+rX/PBbXOkynXkmQIDAQABAoIBAQCD/TJVGK5l/8IC N8FrVJRj/a9aEDkFBmLYwJ1HvIBy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jD/hEMTmFM88KJ5Br1iB3sxkFOFmbFF8iI8jNaONFOR3tfcECzioZN8 MiW+ThdVLtiL0JIa4YWs6/X9FJh57kopBDR4sDIUw7FKFz6drgSApps= -----END RSA PRIVATE KEY----- (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.(FileInputStream.java:138) at java.io.FileInputStream.(FileInputStream.java:93) at com.jcraft.jsch.Util.fromFile(Util.java:518) at com.jcraft.jsch.KeyPair.load(KeyPair.java:554) ... 10 common frames omitted

2022-03-31 08:29:47.607 INFO 6465 --- [ scheduling-1] c.b.o.aspect.InstanceHealthAspect

ixrjog commented 2 years ago

如下命令试下

login 1 -A # 高权限账户登录
login 1 --account root_hy # 指定账户登录
unixtommy commented 2 years ago

opscloud shell>login 1 -A java.lang.NullPointerException Details of the error have been omitted. You can use the stacktrace command to print the full stacktrace. opscloud shell>login 1 --account root_hy java.lang.NullPointerException Details of the error have been omitted. You can use the stacktrace command to print the full stacktrace. opscloud shell>stacktrace java.lang.NullPointerException at com.baiyi.opscloud.sshserver.command.server.ServerLoginCommand.login(ServerLoginCommand.java:103) at com.baiyi.opscloud.sshserver.command.server.ServerLoginCommand$$FastClassBySpringCGLIB$$e626b320.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89) at com.baiyi.opscloud.sshserver.aspect.InvokeSessionUserAspect.around(InvokeSessionUserAspect.java:78) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) at com.baiyi.opscloud.sshserver.command.server.ServerLoginCommand$$EnhancerBySpringCGLIB$$766110b9.login() at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282) at org.springframework.shell.Shell.evaluate(Shell.java:180) at com.baiyi.opscloud.sshserver.ExtendedShell.evaluate(ExtendedShell.java:94) at com.baiyi.opscloud.sshserver.ExtendedShell.run(ExtendedShell.java:84) at com.baiyi.opscloud.sshserver.ExtendedShell.run(ExtendedShell.java:62) at com.baiyi.opscloud.sshserver.SshShellRunnable.run(SshShellRunnable.java:227) at java.lang.Thread.run(Thread.java:748) 一样的错误,会是配置的问题?

ixrjog commented 2 years ago

看问题好像是sshkey没配置

  1. 凭据配置参考(公钥、私钥都填上并注意格式,保存后数据会加密并且无法看到内容) image

  2. 服务器账户配置参考 image

unixtommy commented 2 years ago

解决了。这个用户名必须得是操作系统中真实存在的

QQ20220331-171434@2x

新问题: 服务器里的账户是不能删除的吗 ?我测试了服务器数量为零的账户也不能删除

QQ20220331-171557@2x
ixrjog commented 2 years ago

我看了下代码的确没有删除接口,一般不需要删除你可以修改这个账户为有效的账户即可 image

ixrjog commented 2 years ago

删除代码开发完成 https://github.com/ixrjog/opscloud4/commit/5be5d8df277eb508b424c717fa21cdd0682c53fc 需要在RBAC中新增资源(API)

unixtommy commented 2 years ago

OK多谢