Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Here is an excerpt of the /etc/passwd file on a remote machine.

root:x:0:0:root:/root:/bin/bash
valid:x:0:0::/home/valid:/bin/rbash

As you can see, valid is an alternative name for root.

I can ssh to any of the accounts with a regular ssh command:

ssh root@remoteMachine
[...]
# whoami
root
# pwd
/root

and

ssh valid@remoteMachine
[...]
> whoami
<command unknown>
> pwd
<command unknown>

(we disabled the commands with rbash)

Now, however, when connecting to the remoteMachine as user "valid" with libssh, remote-running whoami returns root, and pwd returns /home/admin. It also appears the shell everything runs in is rbash (found with ps -ef | grep tototototo)

The question is: is this some kind of a bug in libssh, or is it a bug in ssh that won't appear in command-line ssh ?

share|improve this question

migrated from stackoverflow.com Jun 27 '13 at 6:09

This question came from our site for professional and enthusiast programmers.

    
That's weird: the shell is enforced by the server, and the client should have no way to know that valid and root are the same user. What unix variant and ssh implementation is the server running? Can you post the server logs (from /var/log/auth.log or similar)? Do you have any aliases in ~/.ssh/config? Have you checked that no multiplexing is being done? –  Gilles Jun 11 '13 at 21:56
    
@Gilles: Here is what I have: client side: $ uname -a Linux Debian6 2.6.32-5-686 #1 SMP Mon Jun 13 04:13:06 UTC i686 GNU/Linux $ ssh -v OpenSSH_5.5p1 Debian6, OpenSSL 0.9.8o 01 Jun 2010 Server side: $ uname -a Linux #Company Name# 2.6.32-33-generic #72_Ubuntu SMP Fri Jun 29 21:08:37 UTC 2011 i686 GNU/Linux $ ssh -v OpenSSH_5.3p1 Debian_3ubuntu7, OpenSSL 0.9.8k 25 Mar 2009 There is no /home/admin/.ssh directory. /root/.ssh contains no configure file/directory. –  fzd Jun 12 '13 at 6:57
    
@Gilles: When running my code on client side, here are the logs in /var/log/auth.log: Accepted password for valid from 192.168.1.20 port 33513 ssh2 pass_unix (sshd:session) session opened for user valid by (uid=0) pass_unix (sshd:session) session closed for user valid Now, the only thing that changes is that, when I use the command line ssh, the port number changes. (to something in the lines of 57337) –  fzd Jun 12 '13 at 7:00
    
What's the output of the following command: ssh valid@remoteMachine 'echo $BASHOPTS; echo $BASH $HOME; whoami'? Does it change if you pass the option -t to ssh? What if you run ssh interactively and type these commands? And with libssh? What do the startup files in /home/admin contain (.profile, ,bash_profile, .bash_login, .bashrc)? –  Gilles Jun 12 '13 at 9:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.