我一直在学习如何使用paramiko
包,结果却发现我所有的密码都是以纯文本形式存储在IPython的%hist
中的。不怎么好。
因此,我需要删除存储在%hist
中的特定部分。说到这里,我不想抹掉整个历史。-只有我粗心大意地键入password =
或类似选择的术语的部分。
谢谢
我不需要的评论:
%clear
仅清除会话。它不会擦除历史记录。发布于 2013-10-26 20:40:56
默认情况下,历史记录存储在$(ipython locate)/profile_default/history.sqlite
上。您可以删除文件,或对其执行任何您想要的操作(安全擦除等)。它是一个sqlite文件,因此您可以使用任何sqlite程序加载它并对其进行查询。
检入$(ipython locate)/profile_default/
和其他$(ipython locate)/profile_xxx
,确保您没有任何其他历史文件。$(ipython locate)
通常是~/.ipython/
,但也可以不同:
ls $(ipython locate)/profile_*/*.sqlite
发布于 2016-08-20 04:44:51
一种解决方案是:
sqlite ~/.ipython/profile_default/history.sqlite
delete from history where source like '%password =%';
发布于 2018-07-06 05:09:56
结合@Ovidiu Ghinet的answer和@Matt的accepted answer
sqlite $(ipython locate)/profile_*/*.sqlite || sqlite3 $(ipython locate)/profile_*/*.sqlite
然后在sqlite控制台中:
delete from history where source like '%password%';
select * from history; /* confirm that no passwords left */
.quit /* forgot how to exit sqlite console? ;) */
https://stackoverflow.com/questions/19606275
复制相似问题