The main question is simple. Split openssh public key into rfc 4716 compatible format. The only catch, however, is that it should be in java .
Using ssh-keygen , this is just one line:
ssh-keygen -e -f openssh_key.pub
Unfortunately, I could not find other sources to do this in Java. Even any algorithm or steps necessary for the conversion are not mentioned. They all revolve around using ssh-keygen . Of course, I can use java.exec to invoke the command, but this is the worst case scenario.
An example of an openssh key (saved it in code format to save spaces / newlines as created):
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDwxgE7D3HYLYddNHLMFK8OfpRwwUSgxiB8fbecvkCUEktSpWikvsWTyCnl5p3uSmsGg/F1lwVPXuuVlQ4VZlYqMuEBEMRF9ADdXWWNxjO/Hd7688ow7ocncxl0xKXsH5Fc9GHvE8yfUh94F8Qm9x8M8Uux+XsNEvPG8KI/QUJWndIsHv+m//3nbEEqUTAlzsyY0mjHW/dPORhXcB5WeGH+cBRAhcp5JGKAq26TOsuNY8H+nrlxX6z03xbUN28HHdXv6uKZfpnVpl6tM0khxbh7F+tLYWeUIZ+nYaDBPINv8Mkd6Duqe/GOLtgVUIR76Adijok4w5oaKlTq27xzMurl kaushik@kaushik-HP
Designed using ssh-keygen:
---- BEGIN SSH2 PUBLIC KEY ---- Comment: "2048-bit RSA, converted by kaushik@kaushik-HP from OpenSSH" AAAAB3NzaC1yc2EAAAADAQABAAABAQDwxgE7D3HYLYddNHLMFK8OfpRwwUSgxiB8fbecvk CUEktSpWikvsWTyCnl5p3uSmsGg/F1lwVPXuuVlQ4VZlYqMuEBEMRF9ADdXWWNxjO/Hd76 88ow7ocncxl0xKXsH5Fc9GHvE8yfUh94F8Qm9x8M8Uux+XsNEvPG8KI/QUJWndIsHv+m// 3nbEEqUTAlzsyY0mjHW/dPORhXcB5WeGH+cBRAhcp5JGKAq26TOsuNY8H+nrlxX6z03xbU N28HHdXv6uKZfpnVpl6tM0khxbh7F+tLYWeUIZ+nYaDBPINv8Mkd6Duqe/GOLtgVUIR76A dijok4w5oaKlTq27xzMurl ---- END SSH2 PUBLIC KEY ----
UPDATE: I created a default conversion implementation for those who have similar needs.
java openssh
Kaushik np
source share