How to request new TOR identity in terminal
Asked Answered
D

3

20

I am trying to connect to TOR via telnet in my terminal on my mac osx and to request new identity, but it is not working, I always get this error message:

Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host

I am using this telnet command for the connection:

telnet 127.0.0.1 9051

And idea why is this not working?

thx

Distinction answered 7/6, 2013 at 15:16 Comment(1)
Possible duplicate of How to change tor exit node programmaticallyAnnunciation
V
22

The fastest and easiest way to get "new identity" is send HUP signal.

Tor daemon re-read configurations files and make "new identity".

I keep special bash script for this:

# cat /usr/local/bin/nym 
#!/bin/bash
pidof tor | xargs sudo kill -HUP

My sudoers file full of NOPASSWD:

# cat /etc/sudoers 
....
anonymous       ALL=(ALL) NOPASSWD: ALL
...

Try this.

Venose answered 28/8, 2013 at 1:48 Comment(2)
Instead of pidof tor | xargs sudo kill -HUP why not just do killall -HUP tor?Plication
@MathiasBynens I'm not the OP, but in some docker containers killall isn't installedHankering
G
12

Have you set a control port in your torrc? To make it available via telnet you will need "ControlPort 9051". After that you will want to give tor a NEWNYM signal...

$ telnet localhost 9051
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
AUTHENTICATE
250 OK
SIGNAL NEWNYM
250 OK

You can do this via a script using stem with...

from stem import Signal
from stem.control import Controller

with Controller.from_port(port = 9051) as controller:
  controller.authenticate()
  controller.signal(Signal.NEWNYM)

Thanks for the question! I've added it to stem's faq.

Greenockite answered 16/6, 2013 at 0:9 Comment(1)
If you're using the Tor Browser Bundle you don't need to set a control port, it is already set to 9151.Mcevoy
G
0

For ubuntu users, who have been kicked here by google search engine xD :

$ test your current IP
$ curl -sx socks5://127.0.0.1:9050 ifconfig.co | grep -oP '(?<=Your IP</span>: ).*(?=</span>)'
185.220.100.255

$ to get new NYM just restart TOR service
$ sudo service tor restart

$ but remember a new NYM is not always is a new IP, so check your IP again and redo step 2 if it is the same one
$ curl -sx socks5://127.0.0.1:9050 ifconfig.co | grep -oP '(?<=Your IP</span>: ).*(?=</span>)'
185.220.101.214
Gonsalve answered 13/8, 2020 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.