How to load pem from gateway with Fabric

Viewed 30

I need to create a connection with Fabric 2 using 2 gateways.

c = Connection("user@IP", connect_kwargs={"key_filename": "xxxxx.pem"}, gateway=Connection("user@IP", connect_kwargs={"key_filename": "/home/xxxx/key.pem", gateway=Connection("user@IP", connect_kwargs={"password": "xxxxxxx"})))

The first gateway using the password connects just fine, but the second gateway instead of loading the key.pem file from the gateway host it loads it from my local environment, getting the following

File "/Users/xxxx/Library/Python/3.8/lib/python/site-packages/paramiko/pkey.py", line 321, in _read_private_key_file
    with open(filename, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/xxxxx/key.pem'

The key.pem key also requires a passphrase to be entered which can be passed as a connect_kwargs parameter in Fabric Connection instance.

I have also the issue that in the first gateway connection I cannot create a ~/.ssh/config file due to administration issues.

Is there a way to force paramiko do load the key from the gateway host rather than my local machine?

Thank you all.

1 Answers

Never mind was simpler than I thought...I just downloaded the pem keys on my local environment.

Related