Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/crypto/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
mZdd
lmZdefd��YZdefd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: openssh_keypair
author: "David Kainz (@lolcube)"
version_added: "2.8"
short_description: Generate OpenSSH private and public keys.
description:
    - "This module allows one to (re)generate OpenSSH private and public keys. It uses
      ssh-keygen to generate keys. One can generate C(rsa), C(dsa), C(rsa1), C(ed25519)
      or C(ecdsa) private keys."
requirements:
    - "ssh-keygen"
options:
    state:
        description:
            - Whether the private and public keys should exist or not, taking action if the state is different from what is stated.
        type: str
        default: present
        choices: [ present, absent ]
    size:
        description:
            - "Specifies the number of bits in the private key to create. For RSA keys, the minimum size is 1024 bits and the default is 4096 bits.
              Generally, 2048 bits is considered sufficient.  DSA keys must be exactly 1024 bits as specified by FIPS 186-2.
              For ECDSA keys, size 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 values for ECDSA keys will cause this module to fail.
              Ed25519 keys have a fixed length and the size will be ignored."
        type: int
    type:
        description:
            - "The algorithm used to generate the SSH private key. C(rsa1) is for protocol version 1.
              C(rsa1) is deprecated and may not be supported by every version of ssh-keygen."
        type: str
        default: rsa
        choices: ['rsa', 'dsa', 'rsa1', 'ecdsa', 'ed25519']
    force:
        description:
            - Should the key be regenerated even if it already exists
        type: bool
        default: false
    path:
        description:
            - Name of the files containing the public and private key. The file containing the public key will have the extension C(.pub).
        type: path
        required: true
    comment:
        description:
            - Provides a new comment to the public key. When checking if the key is in the correct state this will be ignored.
        type: str
        version_added: "2.9"

extends_documentation_fragment: files
s�
# Generate an OpenSSH keypair with the default values (4096 bits, rsa)
- openssh_keypair:
    path: /tmp/id_ssh_rsa

# Generate an OpenSSH rsa keypair with a different size (2048 bits)
- openssh_keypair:
    path: /tmp/id_ssh_rsa
    size: 2048

# Force regenerate an OpenSSH keypair if it already exists
- openssh_keypair:
    path: /tmp/id_ssh_rsa
    force: True

# Generate an OpenSSH keypair with a different algorithm (dsa)
- openssh_keypair:
    path: /tmp/id_ssh_dsa
    type: dsa
s|
size:
    description: Size (in bits) of the SSH private key
    returned: changed or success
    type: int
    sample: 4096
type:
    description: Algorithm used to generate the SSH private key
    returned: changed or success
    type: str
    sample: rsa
filename:
    description: Path to the generated SSH private key file
    returned: changed or success
    type: str
    sample: /tmp/id_ssh_rsa
fingerprint:
    description: The fingerprint of the key.
    returned: changed or success
    type: str
    sample: SHA256:r4YCZxihVjedH2OlfjVGI6Y5xAYtdCwk8VxKyzVyYfM
public_key:
    description: The public key of the generated SSH private key
    returned: changed or success
    type: str
    sample: ssh-rsa AAAAB3Nza(...omitted...)veL4E3Xcw== test_key
comment:
    description: The comment of the generated key
    returned: changed or success
    type: str
    sample: test@comment
N(t
AnsibleModule(t	to_nativetKeypairErrorcB`seZRS((t__name__t
__module__(((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyR
�stKeypaircB`sDeZd�Zd�Zed�Zed�Zd�Zd�ZRS(cC`s�|jd|_|jd|_|jd|_|jd|_|jd|_|jd|_t|_|j	|_	d|_i|_i|_
|jdkr�|jdkr�d	n|j|_|jd
kr�|jdd�q�n|jd
kr:|jdkr	d
n|j|_|jd
kr:|jdd�q:n|jdkr�|jdkr^dn|j|_|jdkr�|jdd�q�n|jdkr�d|_ndS(Ntpathtstatetforcetsizettypetcommenttrsatrsa1iitmsgs�For RSA keys, the minimum size is 1024 bits and the default is 4096 bits. Attempting to use bit lengths under 1024 will cause the module to fail.tdsas>DSA keys must be exactly 1024 bits as specified by FIPS 186-2.tecdsaii�i	s�For ECDSA keys, size 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 values for ECDSA keys will cause this module to fail. ted25519(RR(ii�i	(tparamsRRRRRRtFalsetchangedt
check_modetNonet
privatekeytfingerprintt
public_keyt	fail_json(tselftmodule((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt__init__�s2				!!!c	C`s�|j|dt�s|jr�|jdt�ddddt|j�d|jd|jg
}|j	r�|j
d	|j	g�n|j
d	dg�y	tjj|j�r�tj
|jtj�r�tj|jtjtj�nt|_d}tjj|j�rd
}n|j|d|�|j|jdt�d|jg�}|d
j�|_|j|jdt�d|jg�}|d
jd�|_Wq�tk
r�}|j�|jddt|��q�Xn�|j|dt�s�|j|jdt�d|jg�}|d
jd�}ylt|_t|jdd��}|j |d�WdQXtj|jdtjtjtj!tj"�Wn!t#k
r�|jdd�nX||_|j	r�y�tjj|j�rtj
|jtj�rtj|jtjtj�n|jdt�dddd	|j	d|jg}|j|�Wq�t#k
r||jdd�q�Xq�n|j$|j%�}|j&|t�r�t|_n|dd|d<|j&|t�r�t|_ndS(Ntperms_requireds
ssh-keygens-qs-Nts-bs-ts-fs-Ctytdatas-lfis-yfs
Rs%ss.pubtwsaThe public key is missing or does not match the private key. Unable to regenerate the public key.s-os-cs0Unable to update the comment for the public key.R('tisPrivateKeyValidRRtget_bin_pathtTruetstrRRRRtextendtostexiststaccesstW_OKtchmodtstattS_IWUSRtS_IRUSRRRtrun_commandtsplitR tstripR!t	ExceptiontremoveR"R	tisPublicKeyValidtopentwritetS_IRGRPtS_IROTHtIOErrortload_file_common_argumentsRtset_fs_attributes_if_different(	R#R$targst
stdin_datatproctpubkeytetpubkey_ft	file_args((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pytgenerate�sj		. 		''
!'	3
			. !
	c	`s@�fd�}|�r�|j|jdt�d�jgdt�}|ddks�tjj�j�r�|jdd�j�ntS|dj�}t	|d��|d	dd	!j
��ntSd
�}��fd�}��fd�}|�_|s|�o|�o|�S|�o?||�o?|�o?|�S(
Nc`stjj�j�S(N(R0RR1((R#(sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt_check_state�ss
ssh-keygens-lftcheck_rciRs3%s is a directory. Please specify a path to a file.ii����cS`s#|j|j�}|j|t�S(N(RCRRDR(R$RK((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt_check_permssc`s
�j�kS(N(R((tkeytypeR#(sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt_check_typesc`s
�j�kS(N(R((tkeysizeR#(sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt_check_sizes(R8R,R-RRR0tisdirR"R9tinttlowerR (	R#R$R&RMRGR RORQRS((RRRPR#sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyR+�s$	-		c`s��fd�}d����fd�}��fd�}d�}|j|jdt�d�jg�}|djd	�}�|���||�r�|�_n�js�||�S|s�||�o�|�S||�o�|�o�||�S(
Nc`sYtjj�jd�rQt�jdd��}|j�jd�}WdQX|StSdS(Ns.pubtrs 
(R0RR1R>treadR:R(RJtpresent_pubkey(R#(sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt_get_pubkey_contents
cS`sM|rI|jdd�}|d|dt|�dkr>dn|dfStS(Nt iiiR'(R9tlenR(tpubkey_contenttparts((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt
_parse_pubkeys1c`s"�r�d �|�d kStS(Ni(R(RH(R_tpubkey_parts(sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt
_pubkey_valid"sc`s�r�d�jkStS(Ni(RR((R`R#(sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt_comment_valid'scS`s5|j|j�}|dd|d<|j|t�S(NRs.pub(RCRRDR(R$RK((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyRO,ss
ssh-keygens-yfis
(R8R,R-RR:R!R(R#R$R&RZRaRbRORH((R_R`R#sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyR=s		'	
cC`sri|jd6|jd6|jd6|jd6|jrA|jdndd6|jd6|jrd|jndd	6}|S(
s'Serialize the object into a dictionary.RRRtfilenameiR'R R!R(RRRRR R!R(R#tresult((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pytdump?s




cC`s�ytj|j�t|_Wn4tk
rS}|jtjkrTt|��qTnXtjj	|jd�r�y!tj|jd�t|_Wq�tk
r�}|jtjkr�t|��q�q�XndS(s(Remove the resource from the filesystem.s.pubN(
R0R<RR-RtOSErrorterrnotENOENTR
R1(R#texc((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyR<Ps

(	RRR%RLR-R+R=ReR<(((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyR
�s	"	A%-	cC`s]tdtdtdddddddg�d	tdd
�dtdddddddd
ddg�dtdddt�dtdddt�dtdd��dtdt�}tjj|jd�p�d}tjj|�s�|j	d|dd|�nt
|�}|jdkr�|jrp|j
�}|jdpY|j|�pY|j|�|d<|j|�ny|j|�Wq@tk
r�}|j	dt|��q@Xn�|jrtjj|jd�|_|jr�i|_n|j
�}|j|�ny|j�Wn)tk
r?}|j	dt|��nX|j
�}|j|�dS(Nt
argument_specRRR.tdefaulttpresenttchoicestabsentRRURRRRRRtboolRtrequiredRtsupports_check_modetadd_file_common_argst.tnameRs>The directory %s does not exist or the file is not a directoryR(RtdictRR-R0RtdirnameRRTR"R
RRReR+R=t	exit_jsonRLR;R	R1RR R<(R$tbase_dirtkeypairRdRi((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pytmaingsJ!*			1		t__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR0R5Rgtansible.module_utils.basicRtansible.module_utils._textR	R;R
tobjectR
RzR(((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssh_keypair.pyt<module>s$

6!�	8

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]