Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 - https://help.ubuntu.com/8.04/serverg...sh-server.html
and https://help.ubuntu.com/community/SS...dvancedOpenSSH

share|improve this question

3 Answers 3

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

To

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
1  
@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

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.