Browsing articles from "July, 2010"
Jul
28

Automatically Add SSH Key to Your Servers

By bradj  //  Bash, Linux  //  No Comments

I am constantly working with multiple linux servers (mostly Debian). Whenever I create a new server I immediately execute this simple script I created which adds my box’s public key to the server I am trying to communicate with. If you know about SSH and SSH Keys then you know what I am talking about… if not… read this. Basically… an SSH Key circumvents the process of sending a password over the wire which is susceptible for interception and decryption. When connecting to a server under the SSH protocol the server sends the client a key/file that is encrypted with super awesomeness. The client reads the file and is like… dude… you need a password… and you’re all like… ok try this password… and then it’s like ok that works I am going to open the connection now…. and you’re like sweet and are able to start h4xing the crap out of life. The difference between this and normal auth: the SSH client does that communication on the client system instead of doing it over the wire! Yay… not rocket science but whatever.

Anyway… this script I wrote sets this junk up for ya. Is there another way to do it that is probably better? Absolutely. If you know it… then please share! :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
 
usage()
{
cat << EOF
usage: $0 options
 
This script appends your public SSH Key on the server you specify which allows you to ssh into that server without typing a password 
 
OPTIONS:
   -h      Show this message
   -u      Username associated with the server you are accessing
   -s      Server address
   -f      SSH Public key file
 
EXAMPLES:
   ./distributeSSH.sh -u username -s 172.1.1.1 -f ~/.ssh/id_dsa.pub
EOF
}
 
user=
server=
file=
while getopts “hu:s:f:” OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         u)
             user=$OPTARG
             ;;
         s)
             server=$OPTARG
             ;;
         f)
             file=$OPTARG
             ;;
         ?)
             usage
             exit
             ;;
     esac
done
 
if [[ -z $user ]] || [[ -z $server ]] || [[ -z $file ]]
then
     usage
     exit 1
fi
 
echo "User = $user"
echo "IP = $server"
echo "SSH Key file = $file"
 
echo "Uploading file on $server in the home directory of $user"
scp $file $user@$server:~/
echo "Executing necessary commands on $server to configure ssh key"
 
ssh -t $user@$server "if [ ! -d ~/.ssh/ ]; then echo Making ssh directory; mkdir ~/.ssh; else echo Found ssh directory; fi; chmod 700 ~/.ssh; cat ~/id_dsa.pub >> ~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys; rm -f ~/id_dsa.pub"
echo "Configuring client to connect without using password..."
ssh -o PreferredAuthentications=publickey $user@$server echo "add this line to your .bashrc: alias server='ssh -X $user@$server'"
Jul
15

Coming Along…

By bradj  //  News  //  No Comments

So… The site is moving right along! I realized that I needed to change the logo located in the header which actually sparked an interest in creating a logo for myself. So, I did! On top of that, I modified the social links at the bottom of posts to copy a Tiny Url instead of the full bradjanke.com/blah/blah Url. What this means is when you click the Twitter, Facebook, etc icon at the bottom of every post it will show up on the site as a Tiny Url. Hurray for short links! Also, the social link section used to be located below the “About the Author” section. I felt that to be a tad cluttered so, I moved the social links above the “About the Author” section. They are more visible which will hopefully be enticing to…. well… you :)

Oh! I almost forgot… I am going to make a tutorial on how to CSS a site using the Blueprint CSS framework. If you want to learn something then feel from to contact me and I will be more than happy to write a tutorial for you.

Lataz!

Jul
11

BradJanke.com Goes Live

By bradj  //  News  //  2 Comments

After many months of busy schedules I finally found some time to get a skeleton up and running.  There are more features coming but they will take time.  One of the coolest features is an image gallery.  This gallery will contain actual photos of me and places I have been as well as things that I have created.  Check back for updates!