SSH是否会将代码保存在远程计算机中?

huangapple go评论76阅读模式
英文:

Does ssh save the code in the remote computer?

问题

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

在远程计算机上由sudo用户使用ssh运行Python代码时,是否会将代码保存在远程计算机上?根用户是否可以查看实际的Python代码?

英文:

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

答案1

得分: 2

不,命令"ssh user@remotehost < python /home/codes/script.py"不会在远程服务器上保存Python文件。实际上,这个命令是不正确的,会导致错误。

"<"符号用于将文件内容重定向到命令的标准输入。在这种情况下,它被用来将python命令的输出重定向到ssh命令的标准输入,这不是有效的操作。

如果你想要在远程服务器上使用SSH运行位于本地机器上的Python脚本,你可以使用cat命令将脚本的内容发送到远程服务器,并将其传递到python命令,如下所示:

"cat /path/to/local_script.py | ssh user@remotehost python -"

这将把本地Python脚本的内容发送到远程服务器,并使用python命令来执行它。然而,它不会在远程服务器上保存Python文件。

英文:

No, the command "ssh user@remotehost < python /home/codes/script.py" will not save the Python file on the remote server. In fact, this command is not correct and will result in an error.

The < symbol is used to redirect the contents of a file to the standard input of a command. In this case, it is being used to redirect the output of the python command to the standard input of the ssh command, which is not a valid operation.

If you want to run a Python script that is located on your local machine on a remote server using SSH, you can use the cat command to send the contents of the script to the remote server and pipe it into the python command like this:

"cat /path/to/local_script.py | ssh user@remotehost python -"

This will send the contents of the local Python script to the remote server and execute it using the python command. However, it will not save the Python file on the remote server.

huangapple
  • 本文由 发表于 2023年5月6日 21:00:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189031.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定