SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've found the recent need to run a java jar application over ssh. X is forwarded and works fine. When logged in as a normal user over ssh the java command simply is not found. The same user can run java applications locally.
Can someone tell me which config file I need to alter? Or would I have to recompile openssh and add /usr/lib64/java to --with-default-path=?
Yes I know this may not be secure. In my case ssh is only forwarded on the local network, all connections outside of the LAN are blocked.
Sorry, I cannot understand what are you trying to do...
Trying to guess:
- When you has a remote session open via ssh, you can do X forwarding
fine, so any java application with a graphical interface correctly
installed on the remote machine should work fine also.
- The "java not found" seems to be a problem with your path
on the remote machine, why don't try to specify it when
starting the application.
- I don't see how recompiling openssh would help, the issues seems
to be different.
Hope it helps but more information should be useful.
Slackware uses different paths than Ubuntu and CentOS. Java has a predefined path variable, that is not defined in openssh by default. I was hoping there was a config file to alter, and not having to recompile openssh.
I've found the recent need to run a java jar application over ssh. X is forwarded and works fine. When logged in as a normal user over ssh the java command simply is not found. The same user can run java applications locally.
I don't have much detail on how your environment is configured, but have you tried to see what environment settings are available when your target user ssh-es onto the remote server?
One quick test to check out the environment is to execute the printenv command on the remote server as the user which you want to use to run your java program:
ssh <user>@<server> printenv
The output of the command should give you enough information as to whether your remote java command can be found, and whether your environment is set up correctly for the user running the remote command.
To quickly test the remote java execution, you can just run the java -version command on the remote machine:
I don't have much detail on how your environment is configured, but have you tried to see what environment settings are available when your target user ssh-es onto the remote server?
ssh <user>@<server> printenv
ssh <user>@<server> java -version
Hope this tid-bit helps,
GL
The environment is cofigured correctly, as it's just a stock, non mucked with Slackware setup.
At the local machine
Code:
bash-3.1$ id
uid=1000(keith) gid=100(users) groups=11(floppy),17(audio),18(video),19(cdrom),83(plugdev),100(users)
bash-3.1$ java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)
Via ssh
Code:
bash-3.1$ id
uid=1000(keith) gid=100(users) groups=11(floppy),17(audio),18(video),19(cdrom),83(plugdev),100(users)
bash-3.1$ java -version
bash: java: command not found
bash-3.1$ /usr/lib64/java/bin/java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)
This problem intrigued me, and although it's been worked around, it doesn't feel like a neat solution. To the OP: feel free to disregard the following, I'm just exercising the grey matter more than anything else. If you feel like playing hunt the bug with me, I look forward to it
I first thought about getting the output of ls -l /etc/profile.d and ls -l /etc/profile, which would show me what was executable and what was not, and since Java is added to the PATH from /etc/profile.d/jre.{sh,csh} (or jdk.{sh,csh}), this seemed like a good start.
However, we know that logging in locally works, so clearly /etc/profile is working and I'd postulate that jre.sh is executable and in the right place. If there is no jre.sh and the path variables are set elsewhere, then that could be an issue.
So what's the difference between the two setups?
Assuming jre.sh is fine, the another difference is the shell invocation (find out more about shell invocation from man bash). If you're using anything but a login shell, you won't get the full environment you're expecting.
Why would you not have a login shell? Hmm, don't know, so let's have a look around man ssh and see what ssh says.
Quote:
Additionally, ssh reads ~/.ssh/environment, and adds lines of the format
``VARNAME=value'' to the environment if the file exists and users are
allowed to change their environment. For more information, see the
PermitUserEnvironment option in sshd_config(5).
Well, that would be a neat workaround that wouldn't mean recompiling openssh at least, and has given me another link.
Let's check the sshd_config file and see what's set by default:
Code:
#UseLogin no
...
#PermitUserEnvironment no
Well, I'd say that uncommenting those would reverse the default settings, so it looks like, by default, you're using a login shell and have you permissions to change the environment on login.
So, what's not installed, corrupted or has been tweaked with to stop a stock install from working? My first query would have to be, where has java come from?
Like I say, feel free to disregard, but I'm interested in what could cause such a problem!
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.
Hence, by default, OP doesn't have a login shell, nor permission to change the environment on login. One would have to uncomment the lines, and change the "No" to a "Yes".
No ... yes ... no ... how many non-double negatives does it not take for an engineer to not change a lightbulb if it hasn't blown?
I'm with you now, yes, and I would concur with that. Note to self, use a pager to read config files back, not cat ...
So no login shell, no permission to change the environment, and yet my sshd is the same, but my path includes java. Still unsure on where java has come from or what non-default settings are floating around.
Could be worth setting those variables explicitly, in that totally scientific 'just to see what happens' way.
No ... yes ... no ... how many non-double negatives does it not take for an engineer to not change a lightbulb if it hasn't blown?
I'm with you now, yes, and I would concur with that. Note to self, use a pager to read config files back, not cat ...
So no login shell, no permission to change the environment, and yet my sshd is the same, but my path includes java. Still unsure on where java has come from or what non-default settings are floating around.
Could be worth setting those variables explicitly, in that totally scientific 'just to see what happens' way.
I had to read that post 4 or 5 times to get through my thick skull.
Code:
#UseLogin no
I'm guessing, from your posts, if I had changed sshd_config to UseLogin from the default no to yes, ssh would use the login command, and process the profile? By not using the login command, ssh does not read profile, and falls back to the defaults that were passed to the openssh configure?
In the long run, recompiling ssh was simple enough. Even though, myself personally, would have either tab-completed to /usr/lib64/java/bin/java, or created a simple 2 line shell script to launch the application - This wasn't my issue. It was for the woman I sleep next to at night. And we all know the things we have to do to please those creatures
I'm guessing, from your posts, if I had changed sshd_config to UseLogin from the default no to yes, ssh would use the login command, and process the profile? By not using the login command, ssh does not read profile, and falls back to the defaults that were passed to the openssh configure?
Yeah, that seems to be the consensus. What doesn't make any sense is that everyone elses UseLogin is set to no and theirs works. If you ever find out what the true root cause of this issue is, do let us know
Quote:
This wasn't my issue. It was for the woman I sleep next to at night.
Yeah, that seems to be the consensus. What doesn't make any sense is that everyone elses UseLogin is set to no and theirs works. If you ever find out what the true root cause of this issue is, do let us know
I believe it's the Xming ssh client she's using on that PC (has Windows XP). I didn't see an option to uselogin or anything similar. Using ssh from a couple of different Slackware PCs (-current, 12.1, and 12.2) all result in java being in the path. Using Putty directly, also results in java being in the path.
Changing sshd_config to Uselogin Yes (stop/start ssh ) results in Xming not being able to connect.
The PC is not actually ours, but a loaner while we wait on her laptop to be delivered. Gotta love warranties
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.