From the Tor General FAQ
Can I control which nodes (or country) are used for entry/exit? Yes.
You can set preferred entry and exit nodes as well as inform Tor which
nodes you do not want to use. The following options can be added to
your config file torrc or specified on the command line:
EntryNodes $fingerprint,$fingerprint,...
A list of preferred nodes to use for the first hop in the circuit, if possible.
ExitNodes $fingerprint,$fingerprint,...
A list of preferred nodes to use for the last hop in the circuit, if possible.
ExcludeNodes $fingerprint,$fingerprint,...
A list of nodes to never use when building a circuit.
ExcludeExitNodes $fingerprint,$fingerprint,...
A list of nodes to never use when picking an exit. Nodes listed in
ExcludeNodes are automatically in this list. We recommend you do not
use these — they are intended for testing and may disappear in future
versions. You get the best security that Tor can provide when you
leave the route selection to Tor; overriding the entry / exit nodes
can mess up your anonymity in ways we don't understand.
Note also that not every circuit is used to deliver traffic outside of
the Tor network. It is normal to see non-exit circuits (such as those
used to connect to onion services, those that do directory fetches,
those used for relay reachability self-tests, and so on) that end at a
non-exit node. To keep a node from being used entirely, see
ExcludeNodes and StrictNodes in the manual.
Instead of $fingerprint you can also specify a 2 letter ISO3166
country code in curly braces (for example {de}), or an ip address
pattern (for example 255.254.0.0/8). Make sure there are no spaces
between the commas and the list items.
If you want to access a service directly through Tor's Socks interface
(eg. using ssh via connect.c), another option is to set up an internal
mapping in your configuration file using MapAddress. See the manual
page for details.
You can search for node fingerprints by going here: https://metrics.torproject.org/rs.html