I want to login to an interactive shell on a server using SSH and, after logging in, execute two commands.
This works: ssh user1@server -t "cd /home/user2; bash --login"
None of the following work:
ssh user1@server -t "cd /home/user2; bash --login -c 'source /home/user2/.bashrc'"
ssh user1@server -t "cd /home/user2; bash --login -c source /home/user2/.bashrc"
ssh user1@server -t "cd /home/user2; bash --login source /home/user2/.bashrc"
ssh user1@server -t "cd /home/user2; bash --login; source /home/user2/.bashrc"
When I call ssh with the -v flag, I see the following before the ssh session exits:
debug1: Sending command: cd /home/user2; bash --login -c "source /home/user2/.bashrc"
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
I know this might look odd; I need to login as user1 so that I can use software (legally) that can only be run by user1, but I want to run my personal .bashrc and work in my personal working directory. I can not modify /home/user1/.bashrc. Is there any better way to do what I'm trying to do?