Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPython: How to wipe IPython's history selectively & securely?

I have been learning how to use the paramiko package only to discover that all I stored passwords in plain text in IPython's %hist. Not so good.

I therefore need to get rid of particular parts of what is stored in %hist. Saying that, I do not want to wipe the whole history. - Only the parts where I have been careless enough to type password = or similar chosen terms.

Thanks


Comments I don't need:

  • %clear only clears the session. It does not wipe the history.
  • Yes. I will only use xSA_keys from now on.
like image 694
root-11 Avatar asked Oct 26 '13 11:10

root-11


People also ask

How do I delete IPython history?

History is store on $(ipython locate)/profile_default/history. sqlite by default. You can remove the file, and or do any operation you want on it (secure erase, etc..). It's an sqlite file so you can load it with any sqlite program and do query on it.

Where is IPython history stored?

IPython stores its files—config, command history and extensions—in the directory ~/. ipython/ by default. If set, this environment variable should be the path to a directory, which IPython will use for user data.

How do I clean my IPython console?

For both Python shell and IPython shell, they have command history through the arrow key. Clicking the up arrow key will show previously typed commands. To clear the output on Console, use Ctrl-L.


2 Answers

History is store on $(ipython locate)/profile_default/history.sqlite by default. You can remove the file, and or do any operation you want on it (secure erase, etc..). It's an sqlite file so you can load it with any sqlite program and do query on it.

Check in $(ipython locate)/profile_default/ and other $(ipython locate)/profile_xxx that you do not have any other history files. $(ipython locate) is usually ~/.ipython/ but can vary:

ls $(ipython locate)/profile_*/*.sqlite 
like image 167
Matt Avatar answered Oct 18 '22 09:10

Matt


One solution would be:

sqlite ~/.ipython/profile_default/history.sqlite  delete from history where source like '%password =%'; 
like image 28
Ovidiu Ghinet Avatar answered Oct 18 '22 07:10

Ovidiu Ghinet