Esta pergunta foi feita antes no SuperUser. A primeira resposta usa um arquivo remoto que não se encaixa nos seus requisitos, mas a segunda resposta que sugere o uso de um alias local pode ser a solução para o seu problema.
It is importand that the command-to-be-executed be stored on the local machine, as it will contain password to open an encrypted disk. That is the reason why I cannot put the command into .profile on the remote machine.
Isso provavelmente não é seguro. Se eu usar um comando echo
como um comando ssh, ele aparecerá em ps
no servidor remoto:
martin@martin ~ % ssh dev2 "echo hello; ps aux|grep echo"
hello
root 25358 0.0 0.0 5848 1296 ? Ss 11:27 0:00 bash -c echo hello; ps aux|grep echo
root 25362 0.0 0.0 5012 828 ? S 11:27 0:00 grep echo