domingo, 27 de agosto de 2023

Running a "stealth" ssh session (Stealth SSH)

Had an authorized assessment where I needed to hop in and out of a bunch of machines fast, without stacking unknown hosts in my known_hosts and without the terminal complaining about color or size every time i dropped into some minimal shell. One line fixed it.

Run:


~ # ssh -tt \ -o UserKnownHostsFile=/dev/null \ -o StrictHostKeyChecking=no \ user@host 'TERM=xterm-256color exec bash -i'

How this command works:
  1. -tt → forces double pseudo-terminal allocation. gives you a full terminal — color, resizing, interactive commands — even against shells that normally choke on TTY.
  2. -o UserKnownHostsFile=/dev/null → tells SSH not to write anything to known_hosts. no local trail piling up from every test box you touch.
  3. -o StrictHostKeyChecking=no → skips host key checking. worth a pause here: this check exists specifically to catch man-in-the-middle attacks, so this flag turns off the one thing that would warn you if the connection was being intercepted. only makes sense on a network you already trust — authorized test environments, or internal automation against hosts that rotate IPs often enough that babysitting known_hosts isn't worth it.
  4. 'TERM=xterm-256color exec bash -i' → sets a full color terminal and drops straight into an interactive bash, bypassing whatever default shell the server has configured.

one thing worth being straight about, since "stealth" in the title oversells it a bit: this only clears your side of the trail — your local known_hosts. nothing changes on the server. auth.log logs the login normally, last shows the session, and remote shell history stays on unless you handle that separately. real stealth means thinking about both ends of the connection, not just the client.

When to use it: pentesting / red team work, so you don't pollute known_hosts jumping between client environments. automation that needs a clean interactive shell. lab environments where IPs rotate often enough that host key checking is more friction than protection.

Other considerations: only use this on authorized networks, no exceptions. prefer key-based auth over passwords, always. on the server side, set up Match in sshd_config to limit what each account can actually run. for a session that survives a dropped connection, pair this with tmux or screen on the remote end.

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.

pass + GPG + git-remote-gcrypt: Encrypted Password Store Sync with GitHub

The idea was simple: keep my passwords in the terminal with pass , version the encrypted files with Git, and maintain an encrypted backu...