ssh/terminal: use duplicate handle in ReadPassword

os.NewFile assigns finalizer to close file handle
passed into ReadPassword. But that is not expected.
Make a duplicate of original file handle, and pass
copy handle into ReadPassword instead.

Fixes golang/go#23525

Change-Id: I4d6725e9a1cc20defd1b58afc383e35a7f9ee4e9
Reviewed-by: Alex Brainman <>
Run-TryBot: Alex Brainman <>
TryBot-Result: Gobot Gobot <>
1 file changed