The issue is that your ~/.bashrc file is being sourced before the echo test command runs when the SSH session starts. This happens because, by default, SSH sessions that execute a command (via command="..." in authorized_keys) still initialize a login shell, which sources ~/.bashrc.
bash -c with --noprofile and --norcModify the command in your ~/.ssh/authorized_keys to explicitly skip sourcing ~/.bashrc and ~/.bash_profile:
bashcommand="bash --noprofile --norc -c 'echo test'" ssh-ed25519 CENSORED user@host
--noprofile: Skips reading ~/.bash_profile, ~/.bash_login, and ~/.profile.--norc: Skips reading ~/.bashrc./bin/sh Instead of bashIf you don’t need Bash features, use /bin/sh (which typically doesn’t source ~/.bashrc):
bashcommand="sh -c 'echo test'" ssh-ed25519 CENSORED user@host
BASH_ENV to /dev/nullIf you must use Bash, you can force it to skip ~/.bashrc by setting BASH_ENV to /dev/null:
bashcommand="BASH_ENV=/dev/null bash -c 'echo test'" ssh-ed25519 CENSORED user@host
env to Clear Environment VariablesIf the issue is caused by environment variables set in ~/.bashrc, you can clear them:
bashcommand="env -i bash --noprofile --norc -c 'echo test'" ssh-ed25519 CENSORED user@host
env -i: Starts with an empty environment.authorized_keys, it spawns a non-interactive, non-login shell by default.~/.bashrc (depending on the BASH_ENV variable or system configuration).Vibe can make mistakes. Check answers. Learn more