The reason your /etc/profile
and ~/.bash_profile
are not read is that you
are not using an interactive login shell. A “normal” login, e.g. via
ssh myserver
creates an interactive login shell, in contrast to executing
commands provided as argument to ssh
, which use a non-login shell.
An interactive non-login bash reads the files /etc/bash.bashrc
and
~/.bashrc
.
If you want to change the directory for interactive login shells,
add your cd /some/dir
to one of the following files. The first one
found, is being processed, the others are ignored.
~/.bash_profile
~/.bash_login
~/.profile
If your user name or host name is too long to type, create an alias
in ~/.ssh/config
:
Host server
HostName me.and.my.server.somedomain.tld
User daniele
/etc/profile
nor~/.bash_profile
is being read, it looks like you are using an interactive non-login shell. Only login shells read those files. However an interactive SSH session starts a login shell. Is your~/.bashrc
being processed?export PATH=$PATH:/some/path
to~/.bashrc
, it actually gets added, but twice! what's going on?ssh
?alias ssh-server='ssh -t user@server "cd /some/dir/ ; bash"'
. I am now wondering what's the meaning of thatbash
at the end, and whether is affecting something.profile
or.bashrc
. If you want to change your shell, usechsh
. If you want to save some typing, create a shorthand in.ssh/config
.