我想禁用在我的CI系统中使用的git push命令的输出,该命令可能会泄漏敏感信息。
命令是:
git --quiet push > /dev/null 2>&1
所以它不应该在屏幕上打印任何东西。但它仍然有指纹 Password for 'https://xxxx@github.com': 当身份验证失败时。
Password for 'https://xxxx@github.com':
更新: 虽然我不确定,但我想git打电话来了 getpass() 或者类似的东西 /dev/tty 直接的。
getpass()
/dev/tty
Git显式打开 /dev/tty 供阅读 和 写入,用于密码提示。
/开发/tty 大约在1979年被添加到Unix,允许程序获取控制终端的文件描述符,因此当stdin被占用以及stdout和stderr都被重定向时,用户输入成为可能。
/开发/tty
见 How does less take data from stdin while still be able to read commands from user?
less
为了防止密钥登录和解决重定向问题,密码提示通过 /dev/tty . 看看Python的 getpass .