Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Current directory not in path when logging via ssh

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Saloon Keeper
Posts: 28054
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Posts: 28054
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...)
 
author
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
reply
    Bookmark Topic Watch Topic
  • New Topic