Giter Club home page Giter Club logo

Comments (7)

ttlequals0 avatar ttlequals0 commented on June 6, 2024

Can you please supply the command that was run and the full error output?

from autovpn.

neumachen avatar neumachen commented on June 6, 2024

I'm running the python script directly, so it's the standard command, but the output (there are no errors) is just None.

from autovpn.

neumachen avatar neumachen commented on June 6, 2024

I had to modify the pyscript because of the VPC thing.

import time
import boto
import boto.ec2
import sys

keyname=sys.argv[1]
instance_type=sys.argv[2]
region=sys.argv[3]
ami=sys.argv[4]
port=sys.argv[5]
if region:
    conn_region = boto.ec2.connect_to_region(region)
else:
    conn_region = boto.connect_ec2()

def auto_vpn(ami=ami,
                    instance_type=instance_type,
                    key_name=keyname,
                    group_name="vpn-server",
                    ssh_port="22",
                    vpn_port=port,
                    cidr="0.0.0.0/0",
                    tag="vpn-server",
                    user_data=None):


    ec2 = conn_region

    try:
        f = {'group-name':group_name,'vpc-id':'vpc-11111111'}
        group = ec2.get_all_security_groups(filters=f)[0]
    except ec2.ResponseError, e:
        if e.code == 'InvalidGroup.NotFound':
            group = ec2.create_security_group(group_name,
                                              'A group that allows VPN access',
                                              vpc_id='vpc-11111111')
            group.authorize('tcp',ssh_port,ssh_port,cidr)
            group.authorize('udp',vpn_port,vpn_port,cidr)
        else:
            str('haller')
            raise

    if int(port) != int(1194):
        try:
            mgroup = ec2.get_all_security_groups(groupnames=[group_name])[0]
            mgroup.authorize('udp',vpn_port,vpn_port,cidr)
        except ec2.ResponseError, e:
            if e.code == 'InvalidPermission.Duplicate':
                '''fail here'''
            else:
                raise

    reservation = ec2.run_instances(ami,
        key_name=key_name,
        security_group_ids=['sg-11111111'],
        instance_type=instance_type,
        user_data=user_data,
        subnet_id='subnet-11111111')

    instance = reservation.instances[0]
    while instance.state != 'running':
        time.sleep(30)
        instance.update()

        instance.add_tag(tag)

    global host
    host = instance.ip_address
    print "%s" % host


if __name__ == "__main__":
    auto_vpn()

from autovpn.

neumachen avatar neumachen commented on June 6, 2024

Actually, after checking my AWS console, I don't see that it got assigned IP addresses (public or private).

from autovpn.

neumachen avatar neumachen commented on June 6, 2024

Okay, so I fixed that issue, but now the issue is the ssh-keyscan keeps returning 1 even though the instance is already running and when I run ssh-keyscan manually, after the instance is running, it is returning 0.

from autovpn.

ttlequals0 avatar ttlequals0 commented on June 6, 2024

I haven't seen that issue before. are you sure the ssh-keyscan is checking the correct ip address?

from autovpn.

neumachen avatar neumachen commented on June 6, 2024

@ttlequals0 I figured this one out, it was because I didn't have an Internet Gateway.

from autovpn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.