This code should go into the end of the .bashrc file in your home directory on the server.
The prompt will stay structured as default, at least in Ubuntu:
username@hostname:~/directoryname$
[--prompt_color-]:[--dir_color--]$
# Setting color for the prompt
# https://superuser.com/questions/1118683/bash-prompt-to-change-color-when-i-am-logged-into-a-server
#
# Color codes for XTerm
# https://www.ditig.com/256-colors-cheat-sheet
#
# Run only when interactive, i.e. when PS1 is set
if [ -n "${PS1}" ]; then
prompt_color='\033[48;5;16m\033[38;5;166m' # orange(166) on black(16)
dir_color='\033[48;5;16m\033[38;5;87m' # cyan(87) on black(16)
PS1='\['${prompt_color}'\]\u@\h\[\033[m\]:\['${dir_color}'\]\w\[\033[m\]\$ '
unset prompt_color
unset dir_color
fi
The color codes are here:
https://www.ditig.com/256-colors-cheat-sheet
Good practice is to wrap the code in an if-statement, so that the test-statement won't affect any code that you paste after this code.
For several servers, a deployment tool or script would be a good idea to consider.
Inspired from the answer by Matei David, thanks!