mathz.nu Asterisk Blacklist Hobby webbhotell

2010/03/07

SSH keys

Filed under: Server — Mathz @ 18:56
  1. First, install OpenSSH on two UNIX machines, hurly and burly. This works best using DSA keys and SSH2 by default as far as I can tell. All the other HOWTOs I’ve seen seem to deal with RSA keys and SSH1, and the instructions not surprisingly fail to work with SSH2.
  2. On each machine type ssh somemachine.example.com and make a connection with your regular password. This will create a .ssh dir in your home directory with the proper perms.
  3. On your primary machine where you want your secret keys to live (let’s say hurly), type
    ssh-keygen -t dsa

    This will prompt you for a secret passphrase. If this is your primary identity key, make sure to use a good passphrase. If this works right you will get two files called id_dsa and id_dsa.pub in your .ssh dir. Note: it is possible to just press the enter key when prompted for a passphrase, which will make a key with no passphrase. This is a Bad Idea ™ for an identity key, so don’t do it! See below for uses of keys without passphrases.

  4. scp ~/.ssh/id_dsa.pub burly:.ssh/authorized_keys2

    Copy the id_dsa.pub file to the other host’s .ssh dir with the name authorized_keys2.

  5. Now burly is ready to accept your ssh key. How to tell it which keys to use? The ssh-add command will do it. For a test, type
    ssh-agent sh -c 'ssh-add < /dev/null && bash'

    This will start the ssh-agent, add your default identity(prompting you for your passphrase), and spawn a bash shell. From this new shell you should be able to:

  6. ssh burly

    This should let you in without typing a password or passphrase. Hooray! You can ssh and scp all you want from this bash shell and not have to type any password or passphrase.

3 Comments »

  1. Ssh keys.. Ho-o-o-o-t 🙂

    Comment by hd tube porn — 2011/02/20 @ 08:03

  2. Wow, that’s what I was exploring for, what a data!

    present here at this webpage, thanks admin of this site.

    Comment by wohnzimmer gestalten ideen — 2015/08/25 @ 00:17

  3. I have this file on the remote host as ~/bin/log#!/bin/bash -LOGFILE=”~/repo/log”if [ “$1” ]; then grep “$1″ $LOGFILEelse echo -n ‘make entry ‘ read case $REPLY in ”) cat $LOGFILE;; *) echo $(date ‘+%F %T’) $REPLY >> $LOGFILE;; escxeifait 0Then, on each host I sit at, I havealias log=’ssh remote_host_address “bin/log”‘So if I don’t enter any text, I get the file’s contentsand if I do enter text it is time stamped and saved.If I type log “searchterm” I get all the lines containing searchtermP.S. Too bad code can’t be offset to retain indentation

    Comment by Erika — 2015/12/26 @ 16:13

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress