1

I'm running an Ubuntu Server 12.04.5 LTS and when I type sudo su it takes 30+ seconds to open the shell. Searching on internet, this problem seems related to the file /etc/hosts and /etc/hostname.

This isn't really a problem for me to wait, however this is affecting other programs (especially sSMTP wich I use for sending mails from PHP) and Apache is giving the classical "could not reliably determine the server's fully qualified domain name".

So I've checked the hosts file and corrected it, and now the apache error is gone but the other problems persist. sudo su now takes about 10-15 seconds.

Output of uname -n, hostname and hostname -f is:

server.example.com

Output of hostname -a:

server

Contents of /etc/hosts:

127.0.0.1   localhost.localdomain   localhost
127.0.1.1   server.example.com      server

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

This server has a public IPv4 address and the DNS record for server.example.com is correct.

If I try ping server or ping server.example.com they work as expected (resolving to 127.0.1.1)

I've run many servers in the past and this is the only one having this problem. I'm completely stuck, any help is very appreciated. Thanks.

Update 1: the server is also running openvpn with less than 10 clients, but disabling the service has no consequences

Update 2: things tried so far:

1) Changing hostname to "localhost": this solves the problem, but isn't acceptable;

2) This version of /etc/hosts (not working):

127.0.0.1   localhost.localdomain   localhost   server.example.com
127.0.1.1   server.example.com      server

::1     ip6-localhost ip6-loopback   server.example.com
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

3) Current version of /etc/hosts (not working):

127.0.0.1       localhost.localdomain   localhost
127.0.1.1       server.sistema3.it      server

::1     ip6-localhost   ip6-loopback    localhost
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
2
  • is only sudo su affected or does the other commands take time too? Jan 10, 2015 at 13:07
  • Got a try with $ sudo echo -e "test" and it runs immediately... so yes, only sudo su takes forever :(
    – JohnKiller
    Jan 10, 2015 at 13:09

2 Answers 2

1

Try editing your /etc/hosts as follows :

 127.0.0.1   server.example.com 
 127.0.1.1   server.example.com      server

 ::1     ip6-localhost ip6-loopback     server.example.com
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters

Try executing sudo su now and see if it makes a difference.

17
  • nope, no effect :( I've updated my original question
    – JohnKiller
    Jan 10, 2015 at 14:05
  • Try switching your hostname to localhost by typing : sudo hostname localhost and check again. Jan 10, 2015 at 14:11
  • yep. changing that to localhost solves the delay. going back to server.example.com reintroduces the problem
    – JohnKiller
    Jan 10, 2015 at 14:17
  • I've edited the answer. I've replaced the additional words with localhost. Try it out. Can you please update the question with your current hosts file? Jan 10, 2015 at 14:22
  • question updated
    – JohnKiller
    Jan 10, 2015 at 19:37
0

I've finally found the problem, and it wasn't a server issue.

It was a setting in the client, Putty. X11 Forwarding was enabled, and caused all the issues. Switched that off.

I noticed that beacuse when connecting from another computer, it wasn't slow. Then I messed a bit with Putty, and bingo.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .