FirstServed Homepage FirstServed Web Hosting | Housing | Domain Names Order Hosting and Domain names FirstServed Help | Support FirstServed Company Information
FirstServed Technical Blog
  • 15th Apr, 2009

    Hi,

    I thought it would be good to share this simple command to regenerate SSH keys:

    rm -fr /etc/ssh/*key*
    service sshd restart
    (Please be careful when executing this command, it will remove files without confirmation!)

    In normal situations you would never need this…
    However it can be usefull when cloning machines.

     

    Greets,

    Koen

    No Comments
  • 10th May, 2007

    Authenticating with SSH without a password

    Are you just as sick and tired as we are of eternally typing your password when transfering files between servers by using rsync or scp?  Or do you want to run automated tasks that copy files between servers?  Setting up public key authentication between *NIX servers is easy as can be. Try the following steps:

    Generate your key:

    [root@client ~]# ssh-keygen –help
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:

    While an empty passphrase is not secure, it’ll avoid certainly make life easier since the whole point is to avoid having to type in passwords.  ssh-keygen generates two files, id_rsa, which is your private key and which should be kept secure, and id_rsa.pub, the public key you can distribute to servers you want to access.  File permissions for the private key should be 0600, and 0644 for the public key.

    Append your public key to the target server’s /.ssh/authorized_keys file:

    [root@client ~]# cat ~/.ssh/id_rsa.pub | ssh root@server "cat - >> ~/.ssh/authorized_keys"

    That’s it!  You should now be able to move files without entering your password each and every time.

    Note that the solution above is just a quick and dirty one, and it’s not recommended to use pubkey authentication without a passphrase, or to set up a root to root access between servers.  If you chose to use a passphrase, there’s still a way to alleviate the pain of entering your password every time.  Start a session with ssh-agent:

    [root@client ~]# ssh-agent /bin/bash
    [root@client ~]# ssh-add
    Enter passphrase for /root/.ssh/id_rsa:
    Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)

    Enter your passphase when prompted, and you’ll be able to ssh to target servers without having to enter your password.

    Limiting access to a server to certain clients

    As an added precaution, you can limit access to a server by adding a ‘from’ statement to the authorized_keys file.  The from statement can contain multiple addresses separated by commas, and wildcard characters.

    from="client.firstserved.net,192.168.*" ssh-rsa AAAA…== root@client.firstserved.net
    No Comments