Score:-1

Does ssh save the code in the remote computer?

US flag

When running python code using ssh on remote computer by a sudo user, does it save the code in the remote computer ? does the root user can see actual python code?

ssh user@remotehost < python /home/codes/script.py
Score:0
in flag

As you've written that, you're not running code on the remote computer. If you want to run the script locally you'd do:

python script.py

If you want to pipe the output of that script to a remote machine you'd do:

python script.py | ssh user@remotehost

If you want to run the script on the remote machine (though note that the script must already be on the remote machine):

ssh user@remotehost "python script.py"

If you want to run the local script on the remote machine, copy it there first:

scp script.py user@remotehost:
ssh user@remotehost "python script.py"

You can avoid the copy by piping it to a shell on the remote:

cat script.py | ssh user@remotehost 'python -'

The trailing - tells python to read the script from standard input.

I'm not quite sure what will happen in your example as it is actually attempting to pipe the contents of the python binary itself, and the script, to the remote host, which is unlikely to be something you actually want to do.

vidarlo avatar
ar flag
It doesn't have a full path for the binary, so it would *not* pipe the binary in all likelihood.
Sara avatar
md
@vidarlo I have edited the question, the python script was used with full path (of the local machine). So, does it copy into the remote machine ?
vidarlo avatar
ar flag
Doesn't change anything; your command makes *NO* sense.
Sara avatar
md
@vidarlo Got it, both were same, so have put only one.
Sara avatar
md
@vidarlo my command though no sense actually ran the program and got some outputs. How can I locate the directory on the remote machine where the script was saved (if in a likelihood)
Sara avatar
md
@Synchro Would it be possible to find the file which might have saved in the remote machine
vidarlo avatar
ar flag
What makes you believe that anything was saved?
Sara avatar
md
@vidarlo `I'm not quite sure what will happen in your example as it is actually attempting to pipe the contents of the python binary itself, and the script, to the remote host,...`
in flag
If you just used `user@remotehost` for the ssh connection, it would end up in that user’s home directory, somewhere like `/home/user`.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.