From bash manual
Invoked by remote shell daemon
Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the remote shell daemon, usually rshd, or the secure shell daemon sshd. If Bash determines it is being run in this fashion, it reads and executes commands from
~/.bashrc, if that file exists and is readable. It will not do this if invoked as sh. The
--norcoption may be used to inhibit this behavior, and the
--rcfileoption may be used to force another file to be read, but neither rshd nor sshd generally invoke the shell with those options or allow them to be specified.
Is a shell provided by
ssh username@server login or nonlogin?
If it is a login shell, why doesn't it executes commands from
~/.profile, but from
~/.bashrc according to the bash manual?
My OS is Ubuntu 16.04, but the bash manual isn't OS specific.