美文网首页already
【SSH】JSCH连接SSH报错:Invalid private

【SSH】JSCH连接SSH报错:Invalid private

作者: Bogon | 来源:发表于2022-11-18 14:01 被阅读0次

    JSCH连接SSH报错:Invalid privatekey

    image.png

    环境版本号:
    jsch: jsch-0.1.54.jar
    SSH: OpenSSH_8.0p1, OpenSSL 1.0.2r 26 Feb 2019
    jdk: 1.8

    JSCH连接SSH报错:Invalid privatekey
    https://blog.csdn.net/a17816876003/article/details/107457369

    OPENSSH PRIVATE KEY转换为RSA PRIVATE KEY
    http://www.mayanpeng.cn/archives/132.html

    生成密钥时指定格式,ssh-keygen -m PEM -t rsa,加上参数-m PEM 和 -t rsa ,生成的密钥对。

     ssh-keygen  -m PEM  -t rsa  -b 4096
    
    image.png
    -m key_format
                  Specify  a key format for key generation, the -i (import), -e (export) conversion options, and the -p change passphrase operation.  The latter may be used to convert between OpenSSH private key and PEM private key
                  formats.  The supported key formats are: ``RFC4716'' (RFC 4716/SSH2 public or private key), ``PKCS8'' (PKCS8 public or private key) or ``PEM'' (PEM public key).  By default OpenSSH will write newly-generated  pri‐
                  vate  keys  in its own format, but when converting public keys for export the default format is ``RFC4716''.  Setting a format of ``PEM'' when generating or updating a supported private key type will cause the key
                  to be stored in the legacy PEM private key format.
    
    -b bits
                  Specifies  the number of bits in the key to create.  For RSA keys, the minimum size is 1024 bits and the default is 3072 bits.  Generally, 3072 bits is considered sufficient.  DSA keys must be exactly 1024 bits as
                  specified by FIPS 186-2.  For ECDSA keys, the -b flag determines the key length by selecting from one of three elliptic curve sizes: 256, 384 or 521 bits.  Attempting to use bit lengths other than these three val‐
                  ues for ECDSA keys will fail.  ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the -b flag will be ignored.
    
    
    -t dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa
                  Specifies the type of key to create.  The possible values are ``dsa'', ``ecdsa'', ``ecdsa-sk'', ``ed25519'', ``ed25519-sk'', or ``rsa''.
    
                  This flag may also be used to specify the desired signature type when signing certificates using an RSA CA key.  The available RSA signature variants are ``ssh-rsa''  (SHA1  signatures,  not  recommended),  ``rsa-
                  sha2-256'', and ``rsa-sha2-512'' (the default).
    

    相关文章

      网友评论

        本文标题:【SSH】JSCH连接SSH报错:Invalid private

        本文链接:https://www.haomeiwen.com/subject/yldpxdtx.html