Running a custom profile file on remote host

2019-06-12 20:45发布

I have a custom profile script on a remote host. I'd like to source it when I connect to the host automatically. I cannot change anything on the remote host. Things I've tried but didn't work:

ssh -t myhost '. /local/scratch/scripts/rtc_profile ; bash -l'
ssh -t myhost 'bash -l /local/scratch/scripts/rtc_profile'

I've also tried the following (which works), but it skips all other rcfiles:

ssh -t myhost 'bash --rcfile /local/scratch/scripts/rtc_profile '

Please help :)

标签: bash ssh
1条回答
淡お忘
2楼-- · 2019-06-12 21:06

You can put the following at the end of your ~/.bashrc:

if [ ! -z "$SSH_CONNECTION" ] ; then
    source /local/scratch/scripts/rtc_profile
fi
查看更多
登录 后发表回答