简体   繁体   English

如何用不同于tomcat的用户在tomcat中运行我的Web应用程序?

[英]How can run my web application in tomcat with a different user than tomcat?

What Ian wanted to do is run some external program or command from my WEB application (.sh, .pl even use directly ProcessBuilder or Runtime) Ian想要做的是从我的WEB应用程序中运行一些外部程序或命令(.sh,.pl甚至直接使用ProcessBuilder或Runtime)

I achived to run the program or commands in my server, but the problem is that all of then are running as tomcat user. 我可以在服务器上运行程序或命令,但是问题是所有这些都以tomcat用户身份运行。 Then, for instance when I try to use ssh with public key I need to do a sudo -u "user" and then run the program or command. 然后,例如,当我尝试将ssh与公共密钥一起使用时,我需要执行sudo -u“ user”,然后运行程序或命令。 But unfortunatelly, I dont know why, it deesn't work. 但不幸的是,我不知道为什么,它不起作用。

After three days of troubleshooting, prof&error and google it, I'm thinking to run my application or procces wit a diferent user, thus avoid to use sudo command. 经过三天的故障排除,prof&error和google之后,我正在考虑运行我的应用程序或使用其他用户进行处理,因此避免使用sudo命令。

Then, I would like to know if somebody could tell me how I can do it or if there is any other best way to do that. 然后,我想知道是否有人可以告诉我我该怎么做,或者是否有其他最佳方法可以做到这一点。

Finally what I've done is to exacute my ssh throught JSch and public key authentication. 最后,我要做的是通过JSch和公钥身份验证执行ssh。 On this way I dont need to use sudo command since I can point out my user and private key. 这样我就不需要使用sudo命令,因为我可以指出我的用户和私钥。 Oviously it's not run tomcat with different user but it fix my problem. 显然,它不是用其他用户运行tomcat的,但是它可以解决我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在tomcat中部署将在不同端口上运行的多个Web应用程序? - How to deploy multiple web application in tomcat which will run on different ports? Tomcat为什么找不到我的Web应用程序? - Why can Tomcat not find my web application? Tomcat运行服务而不是Web应用程序 - Tomcat to run a service not web application 无法运行第一个Web应用程序Tomcat + Intellij - Can`t run first web application Tomcat + Intellij Solr是一个Web应用程序,可以与Tomcat上的Spring应用程序在同一实例上运行吗? - Is solr a web application that can run on the same instance as a spring app on tomcat? 我如何在NetBeans中通过tomcat运行的Java Web应用程序中测量CPU和内存 - How can I measure CPU and Memory in java web application run through tomcat in netbeans 如何更新Tomcat Web应用程序? - How to update Tomcat Web application? 如何配置Java Jersey在与Web应用程序不同的端口上运行的Tomcat - How To Configure Tomcat That Java Jersey Runs On Different Port As Web Application 如何配置tomcat,以便我可以在本地主机上运行我的(java)Web应用程序 - How to configure tomcat so I can run my (java) web app at localhost 我如何使用域直接访问部署在AWS tomcat中的Web应用程序而不显示端口? - how can i directly access my web application deployed in aws tomcat using domain without showing port?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM