Class UserSSHKeyManager


  • @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
    public class UserSSHKeyManager
    extends Object
    Helper to deal with managing a Jenkins-created per-user SSH key
    Author:
    kzantow
    • Constructor Detail

      • UserSSHKeyManager

        public UserSSHKeyManager()
    • Method Detail

      • getOrCreate

        @NonNull
        public static com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey getOrCreate​(@NonNull
                                                                                                           User user)
        Gets the existing generated SSH key for the user or creates one and returns it in the user's credential store
        Parameters:
        user - owner of the key
        Returns:
        the user's personal private key
      • getPublicKey

        @NonNull
        public static UserKey getPublicKey​(@NonNull
                                           User user,
                                           @NonNull
                                           com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey key)
        Gets a readable SSH-compatible public key a user could paste somewhere
        Parameters:
        user - the user which will be used to build a useful description
        key - the private key to use
        Returns:
        a public ssh key
      • reset

        public static void reset​(@NonNull
                                 User user)
        Resets the user's generated key by deleting it and creating a new one
        Parameters:
        user - user to reset a key for