11

I am trying to establish a SSH connection between a Windows PC and a Linux server(amazon ec2).

I decided to use Fabric API implemented using python.

I have Putty installed on the Windows PC.

My fabfile script looks like this:

import sys
from fabric.api import *


def testlive():
  print 'Test live ...'
  run("uptime")

env.use_ssh_config = False
env.host_string = "host.something.com"
env.user = "myuser"
env.keys_filename = "./private_openssh.key"
env.port = 22
env.gateway = "proxyhost:port"

testlive()

I am running Fabric in the same directory with the private key.

I am able to login on this machine using Putty.

The problem: I am constantly asked for Login password for specified user.

Based on other posts(here and here) I already tried:

  • pass as a list the key file to env.keys_filename
  • use username@host_string
  • use env.host instead of env.host_string

How to properly configure Fabric to deal with proxy server and ssh private key file ?

Community
  • 1
  • 1
John Smith
  • 777
  • 2
  • 14
  • 37
  • `"host.something.com"` equal to `user@ip_addr_numbers` ? Your module how to handle `wellcome` and `handshake` ? – dsgdfg Feb 21 '17 at 12:42

4 Answers4

2

The following should work.

env.key_filename = "./private_openssh.key"

(notice the typo in your attempt)

Alvra
  • 353
  • 2
  • 10
2

Fabric's API is best avoided really, way too many bugs and issues (see issue tracker).

You can do what you want in Python with the following:

from __future__ import print_function

from pssh import ParallelSSHClient
from pssh.utils import load_private_key

client = ParallelSSHClient(['host.something.com'],
                           pkey=load_private_key('private_openssh.key'),
                           proxy_host='proxyhost',
                           proxy_port=<proxy port number>,
                           user='myuser',
                           proxy_user='myuser')
output = client.run_command('uname')
for line in output['host.something.com'].stdout:
    print(line)

ParallelSSH is available from pip as parallel-ssh.

danny
  • 5,140
  • 1
  • 19
  • 31
0

PuTTYgen is what you will use to generate your SSH key then upload the copied SSH key to your Cloud Management portal - See Joyant

SACn
  • 1,862
  • 1
  • 14
  • 29
-1

You will have to generate and authenticate a private key, to do so, you need PuTTYgen to generate the SSH access using RSA key with password, key comment and conform the key passphrase, here is a step by step guide documentation SSH Access using RSA Key Authentication

Hashes
  • 110
  • 8