Monday, December 22, 2025

iterm – Terminals prompting for login and not starting properly anymore

I’ve run into a frustrating issue with iTerm2 and Terminal on my work MacBook Pro (M3 Max Sequoia).

I had set up a few iTerm2 profiles for SSH logins that included passwords. After failing to properly log out from one of the sessions, both iTerm2 and the default Terminal app now prompt me for login credentials every time I open them. My usual password doesn’t work—it seems like it’s asking for the root user specifically.

enter image description here

I’ve tried everything I could find online: removing .zshrc, .zprofile, and the Terminal/iTerm2 preferences (plist files), restarting, etc., but nothing has worked so far.

If I set the iTerm2 profile’s command to /bin/zsh, I can open a running terminal, but it loads without my usual settings, environment variables, or profiles.

I’m really stuck at this point and not sure what I’m missing. Since this is a work laptop, I don’t have admin/root access, so I can’t do a full reset. It feels like some setting or file is corrupted, but I haven’t been able to identify it. (I have also .oh-my-zsh installed if it helps)

Has anyone experienced something similar or found a working solution?

Update

I resolved this issue after working with IT and wanted to share an update in case anyone runs into something similar. It turned out the problem wasn’t related to any files, settings, or system corruption as I initially suspected. Our company uses Ubikeys for authentication, and IT explained that a recent macOS update introduced a bug where the system fails to properly recognize the Ubikey. This caused login prompts to appear even when authentication should have worked.

IT mentioned they reported the issue to Apple, but Apple hasn’t acknowledged it yet. As a workaround, they reset the root password and Ubikey authentication, which restored normal functionality—for now, at least, until the bug resurfaces.

More info

The figure below shows the profiles settings in iTerm2. There is a setting called Command that I highlighted in the red rectangle. I get the login prompt shown above when this is set to its default Login Shell.

enter image description here

I can change the Command setting to Command (shown below), and set it to /bin/zsh/, or zsh --no-rcs, or simply just zsh. In this case, it opens the terminal without the login promot (by the way, this only works for iTerm2, the same workaround does not work with the terminal app for some reason).

enter image description here

The following is the output of zsh -l -v -x with my actual username replaced with myusername. (Note that I deleted ~/.zshrc and ~/.zprofile hoping that it could resolve the issue. That’s why you may not be seeing it in the output.)

~ % zsh -l -v -x
# System-wide profile for interactive zsh(1) login shells.

# Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
# and zshoptions(1) for more details.

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi
+/etc/zprofile:6> [ -x /usr/libexec/path_helper ']'
+/etc/zprofile:7> /usr/libexec/path_helper -s
+/etc/zprofile:7> eval 'PATH="/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/iTerm.app/Contents/Resources/utilities";' export 'PATH;'
+(eval):1> PATH=/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/iTerm.app/Contents/Resources/utilities
+(eval):1> export PATH
# System-wide profile for interactive zsh(1) shells.

# Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
# and zshoptions(1) for more details.

# Correctly display UTF-8 with combining characters.
if [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
    setopt COMBINING_CHARS
fi
+/etc/zshrc:7> [[+/etc/zshrc:7> locale LC_CTYPE
+/etc/zshrc:7> [[ UTF-8 == UTF-8 ]]
+/etc/zshrc:8> setopt COMBINING_CHARS

# Disable the log builtin, so we don't conflict with /usr/bin/log
disable log
+/etc/zshrc:12> disable log

# Save command history
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
+/etc/zshrc:15> HISTFILE=/Users/myusername/.zsh_history
HISTSIZE=2000
+/etc/zshrc:16> HISTSIZE=2000
SAVEHIST=1000
+/etc/zshrc:17> SAVEHIST=1000

# Beep on error
setopt BEEP
+/etc/zshrc:20> setopt BEEP

# Use keycodes (generated via zkbd) if present, otherwise fallback on
# values from terminfo
if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
    source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
else
    typeset -g -A key

    [[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
    [[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
    [[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
    [[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
    [[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
    [[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
    [[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
    [[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
    [[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
    [[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
    [[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
    [[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
    [[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
    [[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
    [[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
    [[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
    [[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
    [[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
    [[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
    [[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
    [[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
    [[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
    [[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
    [[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
    [[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
    [[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
    [[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
    [[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
    [[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
    [[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
    [[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
fi
+/etc/zshrc:24> [[ -r /Users/myusername/.zkbd/xterm-256color-apple ]]
+/etc/zshrc:27> typeset -g -A key
+/etc/zshrc:29> [[ -n $'\C-[OP' ]]
+/etc/zshrc:29> key[F1]=$'\C-[OP'
+/etc/zshrc:30> [[ -n $'\C-[OQ' ]]
+/etc/zshrc:30> key[F2]=$'\C-[OQ'
+/etc/zshrc:31> [[ -n $'\C-[OR' ]]
+/etc/zshrc:31> key[F3]=$'\C-[OR'
+/etc/zshrc:32> [[ -n $'\C-[OS' ]]
+/etc/zshrc:32> key[F4]=$'\C-[OS'
+/etc/zshrc:33> [[ -n $'\C-[[15~' ]]
+/etc/zshrc:33> key[F5]=$'\C-[[15~'
+/etc/zshrc:34> [[ -n $'\C-[[17~' ]]
+/etc/zshrc:34> key[F6]=$'\C-[[17~'
+/etc/zshrc:35> [[ -n $'\C-[[18~' ]]
+/etc/zshrc:35> key[F7]=$'\C-[[18~'
+/etc/zshrc:36> [[ -n $'\C-[[19~' ]]
+/etc/zshrc:36> key[F8]=$'\C-[[19~'
+/etc/zshrc:37> [[ -n $'\C-[[20~' ]]
+/etc/zshrc:37> key[F9]=$'\C-[[20~'
+/etc/zshrc:38> [[ -n $'\C-[[21~' ]]
+/etc/zshrc:38> key[F10]=$'\C-[[21~'
+/etc/zshrc:39> [[ -n $'\C-[[23~' ]]
+/etc/zshrc:39> key[F11]=$'\C-[[23~'
+/etc/zshrc:40> [[ -n $'\C-[[24~' ]]
+/etc/zshrc:40> key[F12]=$'\C-[[24~'
+/etc/zshrc:41> [[ -n $'\C-[[1;2P' ]]
+/etc/zshrc:41> key[F13]=$'\C-[[1;2P'
+/etc/zshrc:42> [[ -n $'\C-[[1;2Q' ]]
+/etc/zshrc:42> key[F14]=$'\C-[[1;2Q'
+/etc/zshrc:43> [[ -n $'\C-[[1;2R' ]]
+/etc/zshrc:43> key[F15]=$'\C-[[1;2R'
+/etc/zshrc:44> [[ -n $'\C-[[1;2S' ]]
+/etc/zshrc:44> key[F16]=$'\C-[[1;2S'
+/etc/zshrc:45> [[ -n $'\C-[[15;2~' ]]
+/etc/zshrc:45> key[F17]=$'\C-[[15;2~'
+/etc/zshrc:46> [[ -n $'\C-[[17;2~' ]]
+/etc/zshrc:46> key[F18]=$'\C-[[17;2~'
+/etc/zshrc:47> [[ -n $'\C-[[18;2~' ]]
+/etc/zshrc:47> key[F19]=$'\C-[[18;2~'
+/etc/zshrc:48> [[ -n $'\C-[[19;2~' ]]
+/etc/zshrc:48> key[F20]=$'\C-[[19;2~'
+/etc/zshrc:49> [[ -n $'\C-H' ]]
+/etc/zshrc:49> key[Backspace]=$'\C-H'
+/etc/zshrc:50> [[ -n $'\C-[[2~' ]]
+/etc/zshrc:50> key[Insert]=$'\C-[[2~'
+/etc/zshrc:51> [[ -n $'\C-[[3~' ]]
+/etc/zshrc:51> key[Delete]=$'\C-[[3~'
+/etc/zshrc:52> [[ -n $'\C-[OH' ]]
+/etc/zshrc:52> key[Home]=$'\C-[OH'
+/etc/zshrc:53> [[ -n $'\C-[OF' ]]
+/etc/zshrc:53> key[End]=$'\C-[OF'
+/etc/zshrc:54> [[ -n $'\C-[[5~' ]]
+/etc/zshrc:54> key[PageUp]=$'\C-[[5~'
+/etc/zshrc:55> [[ -n $'\C-[[6~' ]]
+/etc/zshrc:55> key[PageDown]=$'\C-[[6~'
+/etc/zshrc:56> [[ -n $'\C-[OA' ]]
+/etc/zshrc:56> key[Up]=$'\C-[OA'
+/etc/zshrc:57> [[ -n $'\C-[OD' ]]
+/etc/zshrc:57> key[Left]=$'\C-[OD'
+/etc/zshrc:58> [[ -n $'\C-[OB' ]]
+/etc/zshrc:58> key[Down]=$'\C-[OB'
+/etc/zshrc:59> [[ -n $'\C-[OC' ]]
+/etc/zshrc:59> key[Right]=$'\C-[OC'

# Default key bindings
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
+/etc/zshrc:63> [[ -n $'\C-[[3~' ]]
+/etc/zshrc:63> bindkey $'\C-[[3~' delete-char
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
+/etc/zshrc:64> [[ -n $'\C-[OH' ]]
+/etc/zshrc:64> bindkey $'\C-[OH' beginning-of-line
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
+/etc/zshrc:65> [[ -n $'\C-[OF' ]]
+/etc/zshrc:65> bindkey $'\C-[OF' end-of-line
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
+/etc/zshrc:66> [[ -n $'\C-[OA' ]]
+/etc/zshrc:66> bindkey $'\C-[OA' up-line-or-search
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
+/etc/zshrc:67> [[ -n $'\C-[OB' ]]
+/etc/zshrc:67> bindkey $'\C-[OB' down-line-or-search

# Default prompt
PS1="%n@%m %1~ %# "
+/etc/zshrc:70> PS1='%n@%m %1~ %# '

# Useful support for interacting with Terminal.app or other terminal programs
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
+/etc/zshrc:73> [ -r /etc/zshrc_iTerm.app ']'


Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles