Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide arguments from ps [closed]

I would like to keep my ssh command hidden/disguised from other users.

Example:

ssh user@host -i /my/private/key

Unfortunately this will come up in the ps listing and other users will be able to see the private key file that I am using. Is there a way around this?

(They are logged in as the same user as I am)

like image 280
dogbane Avatar asked Apr 07 '09 08:04

dogbane


4 Answers

If they're logged in as you, there's basically little you can do to stop them from learning that information. If you're on Linux they'll have access to your /proc entries and can learn this information easily.

They can also:

  • delete all your files.
  • send mail in your name to insult the CEO of your company.
  • access all your files and command line history, if any.
  • myriad other things.

This is not a viable way to protect yourself. You need to sort out the identical user problem first.

like image 101
paxdiablo Avatar answered Nov 03 '22 00:11

paxdiablo


On Linux, you can do something like

strncpy(argv[0], "mynewcmdlinehere", strlen(argv[0]));

Don't know about other Unices, sorry.

like image 32
Mihai Limbășan Avatar answered Nov 02 '22 23:11

Mihai Limbășan


Hiding command line would require a script, so it's Catch-22, because other ppl having same user will have access to that script.

The solution is quite simple: Use key with pass-phrase. (howto)

like image 3
vartec Avatar answered Nov 02 '22 23:11

vartec


Even if you hide the command line, the user can run lsof to see all the files that your ssh process has open - which will include the identity file. If obscuring the command line is truly the ultimate goal, though, you could start a key agent, load the identity into the agent, and then ssh using that agent. The path to the socket that the agent uses is controleld by an environment variable.

This is by no means security, though. Pax is right - the "logged in as the same user" issue is what really should be solved here. Stop using someone else's account. ;)

like image 2
dannysauer Avatar answered Nov 03 '22 00:11

dannysauer