Again, I think this function should not do anything but sftp calls. It should have nothing to do with sudo or temp files.  Also, I don't understand why you're passing a `StringIO` for stdout if you're not reading it later. 