I transfered /etc/* files from one Linux server to another and now I have a strange error. Both are Debian Squeeze.

When I run a command, e.g. ssh, I get an error:

bash: /usr/bin/ssh: No such file or directory

It looks like the binary exists:

-rwxr-xr-x 1 root root 358756 Sep 21 14:30 /usr/bin/ssh

Bash also autocompletes the command when I type ss and press Tab. I tried reinstalling, purging etc but it didn't solve anything. There is probably something cached under /etc/ but I don't know what excatly.

@mrb Same comment about ldd actually running the program to you, too. Its important that people know this, less they try ldd when analyzing an untrusted binary.
–
derobertSep 28 '12 at 14:53

1

ldd doesn't call _start/main as normal when called on a normal dynamically-linked executable, but an executable can be crafted to run arbitrary code on being examined with some versions of ldd.
–
Random832Sep 28 '12 at 16:12

4

@strangefishinthetown You might try removing /etc/ld.so.cache and checking the contents of /etc/ld.so.conf and /etc/ld.so.conf.d. Run ldconfig to rebuild the cache afterwards.
–
Jim ParisSep 28 '12 at 17:36

1 Answer
1

I think Jim Paris's comment is right on the mark. You can get “no such file or directory” even if the specified file exists, if the dynamic loader for that file does not exist. A common case is trying to run a binary from a different architecture that the kernel supports but not the user-land system — typically a 32-bit binary on a 64-bit system that doesn't have 32-bit libraries installed. See Getting "Not found" message when running a 32-bit binary on a 64-bit system for a more detailed explanation of that case.

Here, it's possible that /usr/bin/ssh uses a library that is installed in a different place on the new system. Since you copied the dynamic linker's cache file /etc/ld.so.cache, the dynamic linker is looking for that library in a place where it doesn't exist. Run ldconfig to update the cache.