Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up a ssh server on 10.10(soon to be 11.04) desktop. I'm sure this goes without saying but, I want it to be as simple and secure as possible. I only plan to connect from one other Ubuntu machine. I have a few starter questions -

ssh-keygen -t dsa will create a key.

  • I then simply attach(cat) that key to the end of the authorized_keys2 file on the remote computer?
  • That is secure?
  • What is the difference between the public and private key?
    • How do I get the sshd daemon to start at startup? I'd like to run this headless without X starting.
    • How can I easily start and stop an X session?

references -

share|improve this question
up vote 10 down vote accepted

I think you're making the SSH component harder than it needs to be.

On the remote machine (ssh server) you do:

# apt-get install ssh

This installs ssh, sets it to start on bootup, and starts it up right then

Then you do, on the client machine:

$ ssh-keygen

Answer, the questions when prompted. Then do

$ ssh-copy-id <user>@<ssh server>

Where <username> is the user you want to authenticate as with your key, and <ssh server> is the ip address/host/dns of the SSH server you want to add your key too. Then test it!

$ ssh <user>@<ssh server>

Now that you're in you want to get root perms...

$ sudo su

And, now that you've got root perms, edit /etc/ssh/sshd_config

# vim /etc/ssh/sshd_config

Assuming you know basic vim of course… Now, change the line that reads

PasswordAuthentication yes


PasswordAuthentication no

That's it for setting up SSH on an Ubuntu machine. Now only you can get into it with your key.

share|improve this answer
Excellent breakdown. Thanks a ton – winchendonsprings Apr 24 '11 at 22:36
@Evan Carroll Hey also, opening up the ssh port on my router is safe as long as I require a password/key, correct? – winchendonsprings Apr 24 '11 at 22:41
It's safe, yes. To be even more safe move the SSH port to something other than the default. – Andrew Lambert Apr 24 '11 at 23:29
@Evan - excellent exposition of this. – boehj Apr 24 '11 at 23:33
@Amazed that doesn't actually make it more safe, that just obscures it. – Evan Carroll Apr 25 '11 at 0:44

There are two commands you must give. The first installs and sets up SSH, the second tests the setup:

  1. sudo apt-get install ssh
  2. ssh localhost

Here is a more detailed explanation. On the server:

  1. Open up a terminal window
  2. Type apt-get install ssh and answer Y when prompted to install. Note that SSH2 RSA and DSA keys are created automatically as part of the install.
  3. Test the install by typing ssh localhost. That command starts an SSH session on the current machine. The RSA fingerprint is displayed along with a query asking if you want to continue. Answer yes to connect. After doing this I popped over to a windows machine and easily used Putty to connect to my Ubuntu server.
share|improve this answer

The private key is exactly that- private. Put a passphrase on it, and don't give anyone access to it. The public key is the one that you push to the servers that you want to access.

share|improve this answer

You must log in to answer this question.

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