Category: “

How to add an SSH public key to your Linux user account

Click here for the quick copy-paste option

Hi there, this is something that helps me out frequently so I wanted to share it with the community.

If you are at all security conscious, you will want to use public/private key authentication, instead of regular passwords, when authenticating to your servers.

This short guide will explain, quite simply, how to add your SSH private key to your server, so you can authenticate with your public key. This guide assumes you already have your public key to hand. I am using Debian 7, however it will work with many other popular distributions of Linux such as CentOS and Ubuntu.

1. Login to your server, and change to your home directory.

cd ~

2. Create a new folder called .ssh.

mkdir .ssh

3. Set the permissions on .ssh to 700.

chmod 700 .ssh

4. Change into that directory.

cd .ssh

5. Create a new file called authorized_keys.

touch authorized_keys

6. Set the permissions to 600 (many applications including OpenSSH will reject your key by default, if it’s accessible by other users).

chmod 600 authorized_keys

7. Open the file with a text editor (I use vi), and paste your keys in.

vi authorized_keys

That’s it. Now disable password authentication in SSH to improve the security of your box.

Thanks for reading.

Here are all the commands together in-case you are want a quick copy and paste job:

cd ~
mkdir .ssh
chmod 700 .ssh
cd .ssh
touch authorized_keys
chmod 600 authorized_keys
vi authorized_keys

Creating central git repository

Cloud based source control systems such as github are a great addition to the everyday toolkit of the software engineer. However, what if you want to host your own local git repository? Maybe for security, budget limitations of just personal preference?

This post will explain how you can do just that. During this explanation I am using Debian 7, but it should work on other operating systems too.

Let’s get started.

1. Install git

sudo apt-get install git

2.  Create a directory. The name does not matter at this point, since this will only be a temporary directory. I named mine ‘git_project’ and stored it in my home folder.

cd ~
mkdir 'git_project'

3. Now initialise the temp folder as a repository.

cd ~/git_project
git init

4. Now copy the files you want to initialise the repository with into this temp directory. If you plan to add files later, just create a temp file.

cd ~/git_project
touch initial.temp

5. Now add all the files in the repository.

git add *

6. Next, commit the files as the initial commit.

git commit -m 'Initial Commit'

7. Now set it to a bare repo. This means that only the bare git repository will be stored, and not the source code files.

git config --bool core.bare true

8. Now move the hidden git file to your central repository location (I store mine in ~/repo). At the same time give it a project name.

mv .git ~/repo/myproject.git

9. You can now clone this repository using the command line.

git clone[user]/repo/myproject.git

That’s it. In a future post I’ll explain for you can integrate this with an IDE.

How to use Scroll View in Xcode 5 Storyboards

Wondering how to create, populate and configure a Scroll View inside a View Controller using Storyboards in Xcode 5? This is for you.

Let’s get started.

Step 1

Add a blank View Controller to your storyboard.

Blank View Controller

Blank View Controller

Continue reading this article…