How to authorize to CRaSH using ssh and key

2019-04-14 21:25发布

There is a library called CRaSH, that was integrated in spring boot. The docs says, that in order to connect with ssh using key, you must add 2 lines of code in config (link) and write path to a pem key

So, I added those lines, like:

shell.auth=key
shell.auth.key.path=/home/user/.ssh/id_rsa

When I try to connect, it says permission denied (public key) When I change id_rsa to id_rsa.pub it crashes on startup with exception. Maybe because it's not pem key So, I tried to convert it

openssl req -x509 -key id_rsa -nodes -days 365 -newkey rsa:2048 -out id_rsa.pem

it results to: Key type org.bouncycastle.cert.X509CertificateHolder not supported On windows with keys generated by puttygen the picture is almost the same What I'm doing wrong?

1条回答
我命由我不由天
2楼-- · 2019-04-14 21:45

This might be quite late, but this setup helps me to connect with ssh and key to a crash shell (version 1.3.1):

  • I convert my openssh/putty key to pem

    openssl rsa -in authorized.rsa -outform pem -pubout > authorized.pem

  • Then I configured crash via spring:

    <bean class="org.crsh.spring.SpringWebBootstrap">
    <property name="config">
        <props>
            <prop key="crash.auth">key</prop>
            <prop key="crash.auth.key.path">WEB-INF/sshd/authorized.pem</prop>
            <!-- ... -->
        </props>
    </property>
    

After starting my server it is possible to connect with putty:

plink -i authorized.ppk -P 12345 -ssh admin@localhost
查看更多
登录 后发表回答