Initialise paramiko PTY from caller environment

This should solve #2065. It also postpones PTY creation until we know that we actually need it (for sudo).