Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have FreeBSd running with OpenSSH. I set up everything and the connection via SSH worked perfectly. Then I decided to get rid of some not used ports and I obviously uninstalled one that was used by zsh.

When I log in I get the following:

~ # ssh cristian@192.168.1.56
Password:
Last login: Wed Nov  7 21:56:26 2012 from 192.168.1.52
FreeBSD 9.0-RELEASE (GENERIC) #0: Tue Jan  3 07:15:25 UTC 2012

Welcome to FreeBSD!

Before seeking technical support, please use the following resources:

o  Security advisories and updated errata information for all releases are
   at http://www.FreeBSD.org/releases/ - always consult the ERRATA section
   for your release first as it's updated frequently.

o  The Handbook and FAQ documents are at http://www.FreeBSD.org/ and,
   along with the mailing lists, can be searched by going to
   http://www.FreeBSD.org/search/.  If the doc package has been installed
   (or fetched via pkg_add -r lang-freebsd-doc, where lang is the
   2-letter language code, e.g. en), they are also available formatted
   in /usr/local/share/doc/freebsd.

If you still have a question or problem, please take the output of
`uname -a', along with any relevant error messages, and email it
as a question to the questions@FreeBSD.org mailing list.  If you are
unfamiliar with FreeBSD's directory layout, please refer to the hier(7)
manual page.  If you are not familiar with manual pages, type `man man'.

Edit /etc/motd to change this login announcement.

Shared object "libiconv.so.3" not found, required by "zsh"Connection to 192.168.1.56 closed.

The thing is that I have no monitor nor do I have a keyboard (right now) to solve the problem very quickly...

I tried this to force loading a different shell > Force SSH to use a specific shell

Does not work as I get:

~ # ssh cristian@192.168.1.56 /usr/local/bin/sh << EOF
chsh -s /usr/local/bin/bash
EOF
Password:
Shared object "libiconv.so.3" not found, required by "zsh"%    

Any ideas how to solve it without keyboard and monitor?

share|improve this question
add comment

4 Answers 4

up vote 3 down vote accepted

I did this same exact error once. I doubt you'll be able to get the root access needed to change your shell remotely. Another, less likely option is to hack your own box and get root privileges.

I had to connect locally via keyboard and monitor and change to the default shell. Never make root use a userland shell. Always let root use the default shell that comes with the system. If you need or want to use a different shell, start it manually after login. This is what I do now.

And remember, don't do make delete-old-libs in /usr/src unless you absolutely know you won't be needing those libs anymore :-D

share|improve this answer
1  
Also remember: always Always ALWAYS have a user account that uses a system default shell (/bin/sh, /bin/csh, /bin/tcsh) so you can get back in if your favorite custom shell goes screwy. –  voretaq7 Nov 9 '12 at 17:52
    
I accept this answer as it is true :) There was no way to get in via ssh or any other remote way. Actually I had to boot FreeBSD in safe mode and for some reason any changes on the passwd were not taken into consideration. So I created a symlink in /usr/local/bin/zsh that pointed to /bin/csh. This was the only way to get in –  bresc Nov 19 '12 at 20:17
add comment

If sftp works, I would try to upload a ~/.ssh/rc file with the commands I need to run (perhaps echo password | chsh -s /usr/local/bin/bash?) and hope that ssh, as its manual page states, does execute those commands before launching the user's shell.

share|improve this answer
    
scp does not work. I get the same error –  bresc Nov 7 '12 at 15:38
    
Not really scp, but rather sftp. Since sftp is a subsystem, I think it will not be invoked through the shell. –  pino42 Nov 7 '12 at 15:56
    
I just get "Connection closed". So it doesn't work. I assume this was kinda my last chance? –  bresc Nov 7 '12 at 17:22
add comment

Method 1

Try following

    ssh username@hostname "/bin/sh -i"

That will let you login with sh instead of bash if successful.

Method 2

ssh into the box with another user and then su/sudo to regain root access.

share|improve this answer
add comment

bash and zsh both have a dependency on libiconv, so neither will work for you, since you removed it. You can do as John suggested, and tell ssh explicitly to run sh or csh, which are both in the base system and should therefore function correctly, as they have no external dependency on anything in ports.

ssh me@there "/bin/sh -i"

You now have a shell session, where you can install libiconv again. For future reference, it's worth using something like ports-mgmt/pkg_cutleaves to remove ports you no longer need - it makes it much harder to shoot yourself in the foot like this!

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.