Skip to main content
added 387 characters in body
Source Link
lese
  • 2.8k
  • 5
  • 23
  • 32

In addition to what Paul Calabro suggested, which I don't think is your main problem , you should define what command-line interpreter(shell) to use for execute the command on the remote machine, since there could be a different shell from localhost.

I think you will also need the -t param of ssh command:

-t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

Something as follow should get closer to what you are looking for:

ssh -it $KEY $USER@$HOST 'sudo su tom; echo $DATA >> /home/user/file.txt; bash'

Unfortunately, in the concatabove solution the "concat" of sudo su && echo still doesn't work, but using -c parameter of su command should fix

-c, --command=COMMAND pass a single COMMAND to the shell with -c

In addition to what Paul Calabro suggested, which I don't think is your main problem , you should define what command-line interpreter(shell) to use for execute the command on the remote machine, since there could be a different shell from localhost.

Something as follow should get closer to what you are looking for:

ssh -it $KEY $USER@$HOST 'sudo su tom; echo $DATA >> /home/user/file.txt; bash'

the concat of sudo su && echo still doesn't work, but using -c parameter of su command should fix

-c, --command=COMMAND pass a single COMMAND to the shell with -c

In addition to what Paul Calabro suggested, which I don't think is your main problem , you should define what command-line interpreter(shell) to use for execute the command on the remote machine, since there could be a different shell from localhost.

I think you will also need the -t param of ssh command:

-t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

Something as follow should get closer to what you are looking for:

ssh -it $KEY $USER@$HOST 'sudo su tom; echo $DATA >> /home/user/file.txt; bash'

Unfortunately, in the above solution the "concat" of sudo su && echo still doesn't work, but using -c parameter of su command should fix

-c, --command=COMMAND pass a single COMMAND to the shell with -c

added 1 character in body
Source Link
lese
  • 2.8k
  • 5
  • 23
  • 32

In addition to what Paul Calabro suggested, which I don't think is your main problem , you should define what command-line interpreter(shell) to use for execute the command on the remote machine, since there could be a different shell from localhost.

WouldSomething as follow should get closer to what you try something like thisare looking for:

ssh -it $KEY $USER@$HOST 'sudo su tom &&tom; echo $DATA >> /home/user/file.txt; bash'

the concat of sudo su && echo still doesn't work, but using -c parameter of su command should fix

-c, --command=COMMAND pass a single COMMAND to the shell with -c

In addition to what Paul Calabro suggested, which I don't think is your main problem , you should define what command-line interpreter(shell) to use for execute the command on the remote machine, since there could be a different shell from localhost.

Would you try something like this:

ssh -it $KEY $USER@$HOST 'sudo su tom && echo $DATA >> /home/user/file.txt; bash'

the concat of sudo su && echo still doesn't work

In addition to what Paul Calabro suggested, which I don't think is your main problem , you should define what command-line interpreter(shell) to use for execute the command on the remote machine, since there could be a different shell from localhost.

Something as follow should get closer to what you are looking for:

ssh -it $KEY $USER@$HOST 'sudo su tom; echo $DATA >> /home/user/file.txt; bash'

the concat of sudo su && echo still doesn't work, but using -c parameter of su command should fix

-c, --command=COMMAND pass a single COMMAND to the shell with -c

added 1 character in body
Source Link
lese
  • 2.8k
  • 5
  • 23
  • 32

In addition to what Paul Calabro suggested, which I don't think is youyour main problem , you should define what command-line interpreter(shell) to use for execute the command on the remote machine, since there could be a different shell from localhost.

Would you try something like this:

ssh -it $KEY $USER@$HOST 'sudo su tom;tom && echo $DATA >> /home/user/file.txt; bash'

the concat of sudo su && echo still doesn't work

In addition to what Paul Calabro suggested, which I don't think is you main problem , you should define what command-line interpreter(shell) to use for execute the command on the remote machine, since there could be a different shell from localhost.

Would you try something like this:

ssh -it $KEY $USER@$HOST 'sudo su tom; echo $DATA >> /home/user/file.txt; bash'

In addition to what Paul Calabro suggested, which I don't think is your main problem , you should define what command-line interpreter(shell) to use for execute the command on the remote machine, since there could be a different shell from localhost.

Would you try something like this:

ssh -it $KEY $USER@$HOST 'sudo su tom && echo $DATA >> /home/user/file.txt; bash'

the concat of sudo su && echo still doesn't work

Source Link
lese
  • 2.8k
  • 5
  • 23
  • 32
Loading