4

I'm establishing an ephemeral hidden service via Tor, but I wish to reuse the same .onion address. I know to do this I must presist the same private-key every time I run the hidden service, but how do I do this?

I'm basically following the Stem documentation for python, but they don't tell you know to presist your private-key, just how to establish a hidden service.

I could use a non-ephemeral hidden service, but I would like be able to run my .py file to establish a hidden service via usb flash drive.

Any help would be greatly appreciated. Thanks!

migrated from security.stackexchange.com Apr 16 '16 at 18:08

This question came from our site for information security professionals.

1

Why not take a look here at the official docs ? It explicitly says, that key can be provided on creation. Of course, if you've already created an ephemeral hidden service, then no key or other stuff can be fetched, because it's the very meaning of it's ephemerical nature. Create your RSA1024 key and use it, why not?

0

Something similar to this.

from stem import control
controller = control.Controller.from_port(address=TOR_CONTROL_HOST, port=TOR_CONTROL_PORT)
controller.authenticate()
key = 'raw-base64-of-the-rsa-1024-key-here'
onion = controller.create_ephemeral_hidden_service(ports=80, discard_key=True, await_publication=True, key_type='RSA1024', key_content=key)
if not onion.is_ok():
    raise Exception('Failed to publish onion.')

In my case loading the contents of 'key' from a file and if it wasn't there then generating a new one from tor itself by reading the results of publishing a totally ephemeral hidden service.

onion = controller.create_ephemeral_hidden_service(ports=80, discard_key=False, await_publication=True)
if not onion.is_ok():
    raise Exception('Failed to publish onion.')
for o in onion:
    if o != "OK":
        k, v = o.split('=', 1)
        if k == "PrivateKey":
            do_stuff_to_save_private_key(v)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy