I want to be able to set a custom prompt (to help with automating jobs, the prompt should be something I can reliably detect). I found I am able to set the prompt remotely, like this:
wim@wim-acer:~$ ssh guest@192.168.1.124 -i ~/.ssh/guest_nopassphrase
~ # echo $PS1
\w \$
~ # PS1='Setting a custom prompt \w \$ '
Setting a custom prompt ~ # exit
Connection to 192.168.1.124 closed.
Is there a way to do it in one shot in the first place, by using a different ssh command? The suggestion I tried in the answer of a related question didn't work for me:
wim@wim-acer:~$ ssh guest@192.168.1.124 -i ~/.ssh/guest_nopassphrase -t "PS1='Sending a custom prompt \w \$ '; exec sh"
~ # set
HOME='/var/tmp'
IFS='
'
LOGNAME='guest'
PATH='/sbin:/usr/sbin:/bin:/usr/bin'
PPID='1039'
PS1='\w \$ '
PS2='> '
PS4='+ '
PWD=''
SHELL='/bin/sh'
TERM='xterm'
USER='guest'