Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key server: 2to3 . -w #681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

john-peterson
Copy link

python 2 is not available anymore in noble

I really want to use this from the neat android app

I am also looking for an INLINE file generator that create ovpn file single file without links to other files. where is it ? ? ?

python 2 is not available anymore in noble

I really want to use this from the neat android app

I am also looking for an INLINE file generator that create ovpn file single file without links to other files. where is it ? ? ?
@schwabe
Copy link
Contributor

schwabe commented Feb 3, 2025

See the man page and search for inline files. It is quite simple to use and therefore there is no script or similar.

@coderknk
Copy link

Since Python 2 is not available in Ubuntu Noble, you have a few options:

Option 1: Use a Python 2 Docker Container
You can run your Python 2 scripts inside a Docker container that has Python 2 installed.

Install Docker:

bash
Copy
sudo apt update
sudo apt install docker.io
Pull a Python 2 Docker image:

bash
Copy
docker pull python:2.7
Run your script inside the container:

bash
Copy
docker run -v $(pwd):/app -w /app python:2.7 python your_script.py
Option 2: Use a Python 2 Virtual Environment
If you have a Python 2 binary (e.g., from a third-party source), you can create a virtual environment.

Download Python 2:

bash
Copy
wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
tar -xzf Python-2.7.18.tgz
cd Python-2.7.18
./configure
make
sudo make install
Create a virtual environment:

bash
Copy
python2 -m virtualenv myenv
source myenv/bin/activate
Run your script:

bash
Copy
python your_script.py
2. Generating an INLINE .ovpn File
To create a single .ovpn file with all configurations and certificates inline, you need to use the inline directive in OpenVPN. Here's how you can do it:

Steps to Create an INLINE .ovpn File:
Combine all files into one:

Open your existing .ovpn file in a text editor.

Replace references to external files (like ca.crt, client.crt, client.key, etc.) with the actual content of those files.

Example of an INLINE .ovpn File:

plaintext
Copy
client
dev tun
proto udp
remote your.server.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
cipher AES-256-CBC
verb 3

-----BEGIN CERTIFICATE----- (contents of ca.crt) -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- (contents of client.crt) -----END CERTIFICATE----- -----BEGIN PRIVATE KEY----- (contents of client.key) -----END PRIVATE KEY----- -----BEGIN OpenVPN Static key V1----- (contents of ta.key) -----END OpenVPN Static key V1----- Save the file:

Save the file with a .ovpn extension, e.g., client_inline.ovpn.

Use the file:

You can now use this single .ovpn file with any OpenVPN client (like the OpenVPN Android app).

Automating the INLINE .ovpn File Creation
If you want to automate the process of creating an INLINE .ovpn file, you can use a simple Python script (Python 3, since Python 2 is deprecated):

python
Copy

inline_ovpn_generator.py

import sys

def read_file(file_path):
with open(file_path, 'r') as file:
return file.read()

def generate_inline_ovpn(config_path, ca_path, cert_path, key_path, tls_auth_path, output_path):
config = read_file(config_path)
ca = read_file(ca_path)
cert = read_file(cert_path)
key = read_file(key_path)
tls_auth = read_file(tls_auth_path)

inline_config = f"""

{config}

{ca}

{cert} {key} {tls_auth} """
with open(output_path, 'w') as output_file:
    output_file.write(inline_config)

if name == "main":
if len(sys.argv) != 7:
print("Usage: python3 inline_ovpn_generator.py <config.ovpn> <ca.crt> <client.crt> <client.key> <ta.key> <output.ovpn>")
sys.exit(1)

generate_inline_ovpn(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6])
print(f"Generated INLINE .ovpn file: {sys.argv[6]}")

How to Use the Script:
Save the script as inline_ovpn_generator.py.

Run the script:

bash
Copy
python3 inline_ovpn_generator.py config.ovpn ca.crt client.crt client.key ta.key client_inline.ovpn
The script will generate client_inline.ovpn with all files combined inline.

Summary
For Python 2, use Docker or a virtual environment.

For INLINE .ovpn files, manually combine the files or use the provided Python script to automate the process.

This approach ensures compatibility with the OpenVPN Android app and avoids external file dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants