0

I am running MacOS if it matters

I am new to terminal and work in a lab at my uni, we have a server where we ssh into from our laptops. I am using ZSH as my shell and have no plugins besides git installed. My issues is that whenever I press tab after username@ when logging in using ssh, several websites that I have used in the past appear as popups. This is really embarrassing and I haven't been able to find anything online about it. I've fully reset my terminal by getting rid of zsh and uninstalling brew, yet the problem persists. If anybody knows a solution i'd really appreciate it.

2 Answers 2

0

Reinstalling a system-wide installed program, on PCs (Mac included), does not usually remove its user-level settings or data.

Both ZSH and Bash have special cases for tab-completion of various commands. When completing ssh or ssh user@ they usually take suggestions from ~/.ssh/known_hosts and ~/.ssh/config, both of which are user data files for OpenSSH; they don't belong to ZSH nor Brew and wouldn't be touched when reinstalling them.

1
  • I have looked into the ~/.ssh/known_hosts folder, but its only the ssh keys I use to log into the ssh server. Thank you for the tips on ZSH and Bash though. I'm gonna look around any SSH files i find and see if theres a list with recent web domains that data is pulled from to suggest. I have deleted my web history and cookies multiple times, so i don't think it is from there.
    – Wex300
    Commented Oct 27, 2023 at 22:23
0

I found the answer:

I was using a software called self-control as a content blocker, this software would write to my /private/etc/hosts file and write the websites that are being blocked by self-control. oh-my-zsh would read from the etc/hosts file to pull up "known hosts" when pressing tab after ssh @. To fix this, I added this at the bottom of my ~/.zshrc file

zstyle -e ':completion:*:hosts' hosts 'reply=(
  ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//,/ }
  ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}}
)'

I found this command here: Stop zsh incorporating /etc/hosts in autocomplete

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .