Quick answer:
SSH is not the problem. The command you use to reboot is the problem: don't do reboot now
, do reboot
or shutdown -r now
to reboot your system.
The command syntax (since 13.04) has been:
reboot [OPTION]... [REBOOTCOMMAND]
The REBOOTCOMMAND
never existed before. In 12.04, your now
was just ignored but now it's being used... And it's breaking everything.
Long answer, with my tests results and explanation:
I have a similar problem with some servers running 14.04 AND in VPS (hosted at the French OVH provider - running OpenVZ) AND when doing reboot now
inside the server itself.
Like you I've issued the command reboot now
from the console (logged in using SSH). A few second after I pressed RETURN, my session is automatically disconnected.
Like you I've never been able to reconnect to the server via SSH after issuing this command.
So, I decided to open the KVM console provided by OVH. (emulating the direct access using keyboard and screen on a physical server for this kind of virtual server).
I was able to connect to my machine and I saw that she was entering into Single User Mode, waiting for me to press CTRL+D to continue or to enter the root password to go into maintenance mode.
I pressed the key combination to go let the process continue and then was able to SSH into my system again. What was my surpise to see, after running uptime
, that the uptime was not 2 or 3 minutes but yet a lot of day : reboot now
executed inside an Ubuntu 14.04 VPS is not really rebooting but is just asking to go into Single User mode!
From this, I've learned to never ask a reboot from within my VPS but to request it from the command provided on the management interface of the hoster.
Thus there is no problem with your SSH installation. The problem is when you type reboot now
. In fact, I tested it afterward also, if you had typed reboot
(just the word, no option), it would have done what you were intending to do : reboot the server.
Using reboot
with an argument (from the man page) call the command shutdown
with the given arguments.
And indeed, if I execute shutdown now
, I have the same behaviour : the system is not rebooted, it goes into single user mode.
Remark: it looks like it is the intended behaviour as the message appearing on the screen after hiting executing this command says something like :
The system will be brought to the maintenance mode
Maintenance mode or single user mode, this represent the same, a runlevel with noting more than a shell, no network, no network processes, ...
This may be confusing, but note that the correct usage of shutdown
is, for instance : shutdown -h now
to halt the system now or shutdown -r now
to reboot it now.
I wasn't aware that shutdown now
would only bring the system into single user mode. I usually do init S
to achieve this.
Best Answer
To get started with ssh in general, install openssh-server.
On the next restart, this should start up automatically. To connect to the computer remotely, just enter the following in a remote terminal, substituting the ALL-CAPS names for your own:
Now, to take care of the dynamic ip forcing you to recheck the IP all the time:
Get a free account on dyndns.com and choose the name you want to type when you connect.
Once that is done, install "ddclient" on the server machine. This will automatically update the IP address for you with dyndns.
When you run it, it will ask you a series of questions, so have your username, password, and the URL you chose earlier ready to type in. It should also automatically add itself to startup.
That should be it. Now when you ssh, just use the URL you chose instead of your IPADDRESS since this should automatically update if the IP changes.
If you have a router, make sure to forward port 22 to your server! There are lots of guides on this at portforward.com for your specific router.