Results 1 to 10 of 10

Thread: Public and Private Key Setup

  1. #1
    Join Date
    Jun 2011
    Beans
    61
    Distro
    Ubuntu 10.04 Lucid Lynx

    Public and Private Key Setup

    So, I have a question and I can't seem to find anything online that will explain it well enough for me to get it working. I have an http web server at home that I've been slowly working on for a while, and, besides a few quirks, I have most things at least functioning. For security and learning reasons, I'd like to learn to set up ssh keys.

    I have password protected ssh working, but I'd like to set up private and public keys, and I have no idea how to do that. I've generated the keys and set the permissions of ~/.ssh to 700, but it still is only password protected and I have no idea why. I've searched tutorials for setting up ssh keys a bunch of times, but it always comes to a point where I need to put the public key in the authorized keys folder and since I am usually using ssh through puTTy on my work Windows machine, I don't have that.

    Even if I don't copy the public key over to my Windows machine, it should still have the key activated, so I should be locked out, right? I must be doing something wrong somewhere, but I really don't know where. Help please!

    I hope this all makes sense, if you need any more information feel free to ask for clarification or any relevant output. Thanks for your time.

    -Brad

  2. #2
    Join Date
    May 2010
    Location
    uk
    Beans
    8,078
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Public and Private Key Setup

    Hi

    I have had a long day so i need to clarify this.

    The Linux box is your SSH server and your windows box is your sshSSH client running PuTTY ?

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

  3. #3
    Join Date
    Jun 2011
    Beans
    61
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Public and Private Key Setup

    That is correct

  4. #4
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: Public and Private Key Setup

    You have to import the openssh keys to putty.

    Use Keygen

    http://jason.sharonandjason.com/key_...ini_how_to.htm
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  5. #5
    Join Date
    Jun 2011
    Beans
    61
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Public and Private Key Setup

    Thank you for the super fast replies! I have a question, though: where it says "...your public key and should be placed in the ~/.ssh/authorized_keys file for every computer you would like to log in to with this private key." does it mean that I'm saving it to the linux server or the windows machine? If linux server, does that mean that I have to make a new public key for every computer that I want to authorize to access the linux server through ssh? This is the point I get confused at most times, because if it's the Windows machine, which is what I interpret it to mean, where would I save it?

  6. #6
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: Public and Private Key Setup

    When you make a key, there are two files, the public and the private key.

    The public key goes on the SERVER in ~/.ssh/authorized_keys

    The private key is used on the Windows client. You can use the private key on any client and in fact many people carry putty and a set of keys on a USB.

    http://bodhizazen.net/Tutorials/SSH_keys
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  7. #7
    Join Date
    Nov 2008
    Location
    Milky Way
    Beans
    141
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Public and Private Key Setup

    Copy the public key (the one that ends in .pub probably), and append it to the ~/.ssh/authorized_keys file on your linux server:
    Code:
    cat path_to_public_key_file.pub >> ~/.ssh/authorized_keys
    You will also need the private key on your Windows computer, with puTTy.

    Also, check that you have the correct settings in /etc/ssh/sshd_config:

    The "PubkeyAuthentication" setting should be set to yes:
    Code:
    ...
    RSAAuthentication yes
    PubkeyAuthentication yes
    #AuthorizedKeysFile	%h/.ssh/authorized_keys
    ...
    If you change the settings, run
    Code:
    sudo service ssh restart
    Common sense is the collection of prejudices acquired by age eighteen.
    -Albert Einstein

  8. #8
    Join Date
    Jun 2011
    Beans
    61
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Public and Private Key Setup

    Awesome! It took me a while to figure out what I was doing wrong, but it turned out to just be me overlooking puttygen as required for my key to work. I seem to always to rush through instructions and miss important things, oh well, works now.

    A few more questions if anyone can answer them: is it possible for me to copy files from my server to a Windows machine through putty? I had a lot of trouble with this and ended up just giving up and waiting until I got home to use my flash drive; I really don't understand how to properly use scp and I'm not entirely sure it even works with something like putty. Also, I now have the key working, but I can still log in whenever I feel like with just a password kind of defeating the purpose; how do I make it so my server only allows key-based logins? Thank you to everyone who helped, your replies were super quick and I honestly didn't expect to get it working so soon.

    -Brad
    Last edited by Brad_J; August 19th, 2011 at 08:17 AM.

  9. #9
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: Public and Private Key Setup

    To transfer files , use winscp
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  10. #10
    Join Date
    Jun 2011
    Beans
    61
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Public and Private Key Setup

    Quote Originally Posted by bodhi.zazen View Post
    To transfer files , use winscp
    Cool, I think it works, but my server crashed shortly after connecting through winscp. Hopefully it is unrelated, but I'll have to check again when I get home. Thanks again.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •