Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

SSH Error: /bin/bash no such file or directory

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
allegre
Posts: 7
Joined: 2018-01-18 12:10

SSH Error: /bin/bash no such file or directory

#1 Post by allegre »

Hi

i have two machines, a web server and a back up server.
on the backup server there is a user (the same user exists on both servers) who execute a script to backup the web site and the database with rsync
everything was working fine but suddenly not
when i try to ssh that user from the backup to the web server: ssh user@webserver i got an error message: /bin/bash: no such file or directory. connection closed.
the ssh from the other side work well (ssh user@backupserver).
No chroot used for ssh.
Any ideas about this?

Thanks everyone.

User avatar
Ardouos
Posts: 1075
Joined: 2013-11-03 00:30
Location: Elicoor II
Has thanked: 1 time
Been thanked: 4 times

Re: SSH Error: /bin/bash no such file or directory

#2 Post by Ardouos »

Check if openssh-client is installed.
There is only one Debian | Do not break Debian | Stability and Debian | Backports

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

allegre
Posts: 7
Joined: 2018-01-18 12:10

Re: SSH Error: /bin/bash no such file or directory

#3 Post by allegre »

Ardouos wrote:Check if openssh-client is installed.
Yes, i can ssh to other users.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: SSH Error: /bin/bash no such file or directory

#4 Post by debiman »

ssh has LOADS of options (both the client and the daemon).
and you haven't told us anything about how it is configured on client and daemon.

please show us real commands issued and full output received.
use code tags for that.

also, verbose:

Code: Select all

-v      Verbose mode.  Causes ssh to print debugging messages about its progress.  This is helpful in debugging connection, authentication, and configuration problems.  Multiple -v options increase
             the verbosity.  The maximum is 3.

allegre
Posts: 7
Joined: 2018-01-18 12:10

Re: SSH Error: /bin/bash no such file or directory

#5 Post by allegre »

debiman wrote:ssh has LOADS of options (both the client and the daemon).
and you haven't told us anything about how it is configured on client and daemon.

please show us real commands issued and full output received.
use code tags for that.

also, verbose:

Code: Select all

-v      Verbose mode.  Causes ssh to print debugging messages about its progress.  This is helpful in debugging connection, authentication, and configuration problems.  Multiple -v options increase
             the verbosity.  The maximum is 3.
Hi,

The command i use to connect from the backup to the web server is: ssh syncuser@srv-web
the syncuser account is on both machines.
the ssh -vvv syncuser@srv-web command gives at the end:

Code: Select all

debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/syncuser/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp 29:15:d2:96:70:3d:61:64:66:4e:43:4d:62:55:77:c0
debug3: sign_and_send_pubkey: RSA 29:15:d2:96:70:3d:61:64:66:4e:43:4d:62:55:77:c0
debug1: Authentication succeeded (publickey).
Authenticated to 172.16.1.147 ([172.16.1.147]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug1: Sending environment.
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env SSH_CLIENT
debug3: Ignored env SSH_TTY
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env MAIL
debug3: Ignored env PATH
debug3: Ignored env PWD
debug1: Sending env LANG = fr_FR.UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Linux srv-web 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u1 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Jan 18 19:38:53 2018 from 172.16.1.146
/bin/bash: No such file or directory
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug2: channel 0: rcvd eow
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)

Connection to 172.16.1.147 closed.
Transferred: sent 3680, received 2448 bytes, in 0.0 seconds
Bytes per second: sent 305541.5, received 203251.5
debug1: Exit status 1
The ssh from srv-web work well (ssh syncuser@srvweb-bckp)

Please tell me if you need any other informations.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: SSH Error: /bin/bash no such file or directory

#6 Post by debiman »

it would seem that bash is not installed on the remote machine.
are you sure it uses bash, and not some other shell?
are you sure this is an ssh problem, and not a problem with the remote server itself?

wild guess: maybe ssh can be configured to look for bash, and errors out if it doesn't find it?

did you read the docs?

allegre
Posts: 7
Joined: 2018-01-18 12:10

Re: SSH Error: /bin/bash no such file or directory

#7 Post by allegre »

debiman wrote:it would seem that bash is not installed on the remote machine.
are you sure it uses bash, and not some other shell?
are you sure this is an ssh problem, and not a problem with the remote server itself?

wild guess: maybe ssh can be configured to look for bash, and errors out if it doesn't find it?

did you read the docs?
bash is installed, ssh was working well before.
I can ssh to other users on the remote server, only "syncuser" fails.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: SSH Error: /bin/bash no such file or directory

#8 Post by Head_on_a_Stick »

I've never used SSH but have you checked

Code: Select all

echo $PATH
Whenever I chroot, this is usually needed:

Code: Select all

. /etc/profile
But maybe I am way off here.
deadbang

allegre
Posts: 7
Joined: 2018-01-18 12:10

Re: SSH Error: /bin/bash no such file or directory

#9 Post by allegre »

Head_on_a_Stick wrote:I've never used SSH but have you checked

Code: Select all

echo $PATH
Whenever I chroot, this is usually needed:

Code: Select all

. /etc/profile
But maybe I am way off here.
echo $PATH gives:
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: SSH Error: /bin/bash no such file or directory

#10 Post by GarryRicketson »

by allegre »No chroot used for ssh.
Any ideas about this?

SSH Error: /bin/bash no such file or directory

"No chroot used for ssh."
Maybe not a good idea ???
https://stackoverflow.com/questions/295 ... server-ssh
=============

https://serverfault.com/questions/25423 ... -directory
"Any ideas about this?"
It would be a good idea to read some of the other results as well.

reinob
Posts: 1189
Joined: 2014-06-30 11:42
Has thanked: 97 times
Been thanked: 47 times

Re: SSH Error: /bin/bash no such file or directory

#11 Post by reinob »

allegre wrote:bash is installed, ssh was working well before.
I can ssh to other users on the remote server, only "syncuser" fails.
do the other users have /bin/bash as default shell?
if no, does /bin/bash actually exist and work?
is it listed in /etc/shells as allowed?

can you confirm that nothing in your web server's sshd_config changes the default behavior for your backup user?
(things like ForceCommand jump to mind)

can you also check /home/syncuser/.ssh directory of your web server's backup user?
Specifically, if a "rc" script is present it will be run instead of the user's shell.

can you, from the backup server, do something like "ssh syncuser@webserver -t /bin/sh"
this should run /bin/sh - which is usually /bin/dash in debian - instead of the user's shell.

Good luck.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: SSH Error: /bin/bash no such file or directory

#12 Post by debiman »

another good-looking search result (lots to read & try out):
https://ubuntuforums.org/showthread.php?t=2031679

allegre
Posts: 7
Joined: 2018-01-18 12:10

Re: SSH Error: /bin/bash no such file or directory

#13 Post by allegre »

Thank you for your answers.

other users do have /bin/bash as default shell.
/bin/bash exists and works well

Code: Select all

syncuser@srv-web:~$ ldd /bin/bash
	linux-vdso.so.1 =>  (0x00007fff558d9000)
	libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f3b4e449000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3b4e245000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3b4deb9000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f3b4e678000)

Code: Select all

syncuser@srv-web:~$ cat /etc/shells 
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/screen

Code: Select all

syncuser@srv-web:~$ ls -l /bin/ba*
-rwxr-xr-x 1 root root 975488 déc.  30  2012 /bin/bash
The sshd_config seems normal:

Code: Select all

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

#Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.

UsePAM yes

Subsystem sftp internal-sftp
match group sftp
ChrootDirectory /var/www/
X11Forwarding no
AllowTcpForwarding no
the .ssh folder contains just the 4 files public and private key, know hosts and auth keys
the ssh syncuser@srv-web -t /bin/bash give the same error: /bin/bash no such file or directory.
i changed syncuser shell on the web server to /bin/sh, the i tried to ssh from the back up, i got the following error: /bin/sh no such file or directory.

reinob
Posts: 1189
Joined: 2014-06-30 11:42
Has thanked: 97 times
Been thanked: 47 times

Re: SSH Error: /bin/bash no such file or directory

#14 Post by reinob »

allegre wrote: The sshd_config seems normal:

Code: Select all

...
match group sftp
ChrootDirectory /var/www/
X11Forwarding no
AllowTcpForwarding no
WTF?
Can it be that your syncuser belongs to the sftp group?
If so, that explains it. You're chrooting to /var/www, and I bet /var/www/bin/bash does not exist.

allegre
Posts: 7
Joined: 2018-01-18 12:10

Re: SSH Error: /bin/bash no such file or directory

#15 Post by allegre »

reinob wrote:
allegre wrote: The sshd_config seems normal:

Code: Select all

...
match group sftp
ChrootDirectory /var/www/
X11Forwarding no
AllowTcpForwarding no
WTF?
Can it be that your syncuser belongs to the sftp group?
If so, that explains it. You're chrooting to /var/www, and I bet /var/www/bin/bash does not exist.
You"re RIGHT!!!! and i don't have any idea about who did that!

Post Reply