+0
how the deuce did he know that I had come from Afghanistan?
+0
Hasibul Alam How the deuce did he know that I had come from Afghanistan?

It's an uncommon/old-fashioned expression expressing frustration/indignation/surprise. It's similar to "How the hell ...." or "How the devil ...".

Take a look at the last entry in the link below.

https://dictionary.cambridge.org/dictionary/english/deuce

+0
Hasibul Alamhow the deuce did he know that I had come from Afghanistan?

My father used this mild expletive. Another expression is:

How in the world did he know...
How in tarnation did he know..