在/ etc / profile和〜/ .bash_profile中添加PATH,但不能通过SSH显示

在Centos 6.x上,

我正在添加一些pathexport PATH=$PATH:/some/path

/etc/profile~/.bash_profile

但是如果通过SSHlogin的话不起作用

它只显示如果我inputsource .bash_profile

我究竟做错了什么?

(NB通过SSHlogin我使用以下别名: alias ssh-server='ssh -t user@server "cd /some/dir/ ; bash"

不读取/etc/profile~/.bash_profile的原因是您没有使用交互式loginshell 。 “正常”login,例如通过

 ssh myserver 

创build一个交互式loginshell,与执行作为ssh参数提供的命令(使用非loginshell)相反。 交互式非loginbash读取文件/etc/bash.bashrc~/.bashrc

如果要更改交互式loginshell的目录,请将cd /some/dir到以下文件之一。 第一个发现,正在处理,其他人被忽略。

 ~/.bash_profile ~/.bash_login ~/.profile 

如果您的用户名或主机名太长,请在~/.ssh/config创build一个别名:

 Host server HostName me.and.my.server.somedomain.tld User daniele