Using an SSH keyfile with Fabric

后端 未结 8 1490
Happy的楠姐
Happy的楠姐 2020-11-28 18:42

How do you configure fabric to connect to remote hosts using SSH keyfiles (for example, Amazon EC2 instances)?

8条回答
  •  鱼传尺愫
    2020-11-28 19:33

    None of these answers worked for me on py3.7, fabric2.5.0 and paramiko 2.7.1.

    However, using the PKey attribute in the documentation does work: http://docs.fabfile.org/en/2.5/concepts/authentication.html#private-key-objects

    from paramiko import RSAKey
    ctx.connect_kwargs.pkey = RSAKey.from_private_key_file('path_to_your_aws_key')
    with Connection(ctx.host, user, connect_kwargs=ctx.connect_kwargs) as conn:
        //etc.... 
    

提交回复
热议问题