Alias fails when defined in .bash_aliases on Ubuntu 20.04.2 over ssh with jump server

The strange placement of the quotes in the error message suggests that the .bash_aliases file has DOS-style CRLF (i.e. \r\n) line endings ex.

$ printf '%s\r\n' "alias lsd='ls -a -g --group-directories-first'" >> ~/.bash_aliases

$ file ~/.bash_aliases
/home/steeldriver/.bash_aliases: ASCII text, with CRLF line terminators

$ . ~/.bash_aliases
$
$ lsd
's: unrecognized option '--group-directories-first
Try 'ls --help' for more information.

You can fix it by setting appropriate UNIX line termination in your text editor, or by passing the file through dos2unix:

$ dos2unix ~/.bash_aliases
dos2unix: converting file /home/steeldriver/.bash_aliases to Unix format...

You will then need to source the file again.