| Author |
Current directory not in path when logging via ssh
|
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
I'm using a soft called TeraTerm as my unix terminal. I encountered the following problem yesterday. I could not execute a script, altough a colleague could. We are both using the same soft, logging to the same server, using the same user. The difference was that I was using ssh, while she was using telnet.
1. If I login to server A with user X using telnet(port:23), the path contains the current directory (".") in it.
2. If I login to server A with user X using ssh(port:22), the path does not contain the current directory (".") in it, which was the problem.
What's the difference between using telnet and ssh ? Why is the path different, although I'm connecting to the same server with the same user ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14568
|
|
I think it's more likely due to what account you logged in under.
Linux/Unix doesn't include the current directory in the path by default no matter how you log in. In fact, some people consider having the current directory in the path as a security risk.
That doesn't, however, mean that you can't set up a login script that adds "." to the PATH environment. Which is probably what happened.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
Stefan Wagner
Ranch Hand
Joined: Jun 02, 2003
Posts: 1923
|
|
He said, he logs in as user X on the same machine, so it shouldn't be the user, nor the users shell setting.
man telnet wrote:
ENVIRONMENT
Telnet uses at least the HOME, SHELL, DISPLAY, and TERM environment variables. Other environment vari‐
ables may be propagated to the other side via the TELNET ENVIRON option.
man sshd wrote:LOGIN PROCESS
When a user successfully logs in, sshd does the following:
1. If the login is on a tty, and no command has been specified, prints last login time and...
9. Runs user's shell or command.
I don't see an obvious difference here, but which configfile is read or isn't may differ, and in the end the configfile might evaluate, if it is called from ssh or telnet.
You may put some
and so on in .bashrc, /etc/bash.bashrc and so on, to see, which one is invoked, or search, where "." is added to the path.
|
http://home.arcor.de/hirnstrom/bewerbung
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14568
|
|
Stefan Wagner wrote:He said, he logs in as user X on the same machine, so it shouldn't be the user, nor the users shell setting.
Users tell me that kind of stuff all the time. My cynicism is leaking out again. But it is true that the various login scripts invoked can vary depending on the login environment. Most commonly that's due to internal/external (in other words, spawning sub-shells) and interactive/non-interactive.
|
 |
Stefan Wagner
Ranch Hand
Joined: Jun 02, 2003
Posts: 1923
|
|
Tim Holloway wrote:
Users tell me that kind of stuff all the time.
Users with more than 10 000 posts should know how important accurate information is, when asking for help, and if they provide this detailed information on their own, my experience is, it is mostly right.
I would have tried the commands myself, but of course, nowadays, nobody uses telnet any more, except firmware-stuff, embedded devices, etc.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
|
I see. So there is actually in difference between login via telnet or via ssh. I'll try to find out which script does not get invoked (when I find some time to...)
|
 |
Sergey Babkin
author
Ranch Hand
Joined: Apr 05, 2010
Posts: 50
|
|
Christophe Verré wrote:I see. So there is actually in difference between login via telnet or via ssh. I'll try to find out which script does not get invoked (when I find some time to...)
There is a difference between
ssh server
and
ssh server command
In the second case the .profile (or whatever exact name your shell uses) is not executed. The first case should be the same as telnet.
|
 |
 |
|
|
subject: Current directory not in path when logging via ssh
|
|
|