MMNCS.COM
  • Web
    • WordPress
    • Joomla
    • Drupal
  • Tips & Tricks
    • Youtube
    • WordPress
    • Windows
    • Web
    • Twitter
    • Linux Ubuntu
    • Google
    • Facebook
    • Drupal
    • Developer
    • Designer
    • Apple
  • Tech News
    • Windows Phone
    • Servers
    • Search Engines
    • Nokia
    • Microsoft
    • iPhone
    • Google
    • Facebook
    • Browsers
    • Apple
  • Social Media
    • Youtube
    • Yahoo
    • Twitter
    • Google+
    • Facebook
  • Server
    • Web Server
      • NGINX
      • Apache Web Server
    • Ubuntu
    • Security
      • Access Control
    • Mail Server
    • Hosting
    • FTP Server
    • Firewall
    • Database
      • MySQL
    • Backup
  • SEO
    • Yahoo Search
    • Google Search
    • Google AdSense
    • Bing
  • Off-Topic
    • Weird
    • Music
    • Fun
    • Documentaries
  • Mobile
    • Windows Phone 7
    • iPhone
    • Android
  • Google
    • Google Translate
    • Google Plus
    • Google PageRank
    • Google Adwords
    • AdSense
  • Design & Dev
    • Webdevelopment
    • Version Control
      • Git Version Control
    • Programming
    • PHP
    • JavaScript
    • HTML
    • Development Environment
    • CSS

Related

  1. How to change your hostname on a Linux Server
  2. How to password protect Apache directory for unwanted users using a htaccess file on a Linux Server
  • Share on Tumblr

How to use Putty or MSysGit on Windows to login securely on Linux via OpenSSH with public and private key pairs

by MMNCS on May 2nd, 2011, updated August 16, 2011
SSH login using public and private keys

This guide shows how to setup Putty or MSysGit to use public and private key pairs on Windows to login securely on a Linux Server.

Why? Taken from Ubuntu community doc. If your SSH server is visible over the Internet, you should use public key authentication instead of passwords if at all possible. If you don’t think it’s important, try logging all of the malicious login attempts you get for the next week. My computer – a perfectly ordinary desktop PC – had over 4,000 attempts to guess my password and almost 2,500 break-in attempts in the last week alone. How many thousand random guesses do you think it will take before an attacker stumbles across your password?

With public key authentication, every computer has a public and a private “key” (a large number with particular mathematical properties). The private key is kept on the computer you log in from, while the public key is stored on the .ssh/authorized_keys file on all the computers you want to log in to. When you log in to a computer, the SSH server uses the public key to “lock” messages in a way that can only be “unlocked” by your private key – this means that even the most resourceful attacker can’t snoop on, or interfere with, your session. As an extra security measure, most SSH programs store the private key in a passphrase-protected format, so that if your computer is stolen or broken in to, you should have enough time to disable your old public key before they break the passphrase and start using your key. Wikipedia has a more detailed explanation of how keys work.

 

Configure OpenSSH on Linux Server:
To enable OpenSSH you have to edit the sshd_config on your server to accept version 2 public key only.

 

nano /etc/ssh/sshd_config

 

Add or modify the following lines:

# Environment variables sent by the client, only version 2 keys
Protocol 2

# Authentication(NO ROOT LOGIN!):
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

# Use public keys and where keys are stored
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
IgnoreUserKnownHosts yes

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

Save your sshd_config, but wait to load your new settings before you have created your ssh keys and be sure to have a fall-back plan if something should go wrong.

Generate OpenSSH private and public key pair(Server-side):
Login on the server as the user you want to use and generate a pair of private and public keys on the Linux side. Here it is seen for the user “user”

Execute `ssh-keygen -t rsa` to generate a version 2 public and private key pair into directory /home/user/.ssh.

ssh-keygen -t rsa

Output:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa)
Created directory '(/home/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
a1:0a:6f:5b:8d:2f:e9:b0:34:28:f5:d1:a7:4b:f3:18 user@hostname
The key's randomart image is:
+--[ RSA 2048]----+
|        . + Eo=. |
|       . = . *.+.|
|        + o + o..|
|         = + +   |
|        S = o .  |
|         . + o   |
|          + .    |
|                 |
|                 |
+-----------------+

Next add the newly created key to a file called “authorized_keys” in your .ssh directory:

cd /home/user/.ssh
cat id_rsa.pub >> authorized_keys

And final and very important. Copy the private key id_rsa to your windows machine. I recommend using winSCP a very handy program.
http://winscp.net/eng/download.php

 

Using MSysGit to login with SSH keys:
The only thing you have to do to get it working in MSysGit is to add a new directory in your home called .ssh where you place the private key id_rsa downloaded from the server. You are now ready to login. If it doesn’t work, check to see that MSysGit looks for the key in your home/.ssh.

ssh user@host

  
Next: Using Putty to login with SSH keys:
 

Pages: 1 2

You may be interested in

  1. How to password protect Apache directory for unwanted users using a htaccess file on a Linux Server
  2. How to change your hostname on a Linux Server

support and subscribe to the site

Follow @mmncs
Posted in Security, Ubuntu Tags: 2011, configuration, Dedicated Server, Education, Guide, Learning, Linux, Linux Ubuntu 11.04, msysgit, openssh, public private keys, putty, security, Server, ssh, Ubuntu 10.04, VPS, windows
« How to change your hostname on a Linux Server
How to backup your MySQL databases automatically with the AutoMySQLBackup script on Linux Ubuntu 11.04 and Debian based systems »


Comments

You can leave a response, or trackback from your own site.
  1. 3-5-2011
    daigoumee

    My partner and I really enjoyed reading this blog post, I was just itching to know do you trade featured posts? I am always trying to find someone to make trades with and merely thought I would ask.

    Reply
  2. 10-5-2011
    cushion

    What a post!! Very informative and easy to understand. Looking for more such posts!! Do you have a myspace?

    Reply

Leave a Reply

Click here to cancel reply.

Trackbacks & pingbacks

  1. 6-5-2011
    Install Setup Git Gitolite Repository Server Windows MSysGit | MMNCS says: [...] Cygwin (20) How to setup an FTP Server with virtual users(no accounts) using vsftpd on ubuntu (10) How to use Putty or MSysGit on Windows to login securely on Linux via OpenSSH with public and privat... (10) The epic new movie from Steven Stringberg – See the trailer here (7) How to password [...]
  2. 18-7-2011
    How to install and setup a Git Repository Server using Gitolite on Linux Ubuntu 11.04 Server and Client | MMNCS says: [...] If you want learn more about how to setup OpenSSH Server using keys you can read this: How to use Putty or MSysGit on Windows to login securely on Linux via OpenSSH with public and privat... [...]

Search terms for this article

  • msysgit pubkey auth,
  • msysgit with public key,
  • ftp server with public key on linux,
  • putty mygit,
  • using putty with msysgit,
  • msysgit ssh key location,
  • adding nano to msysgit,
  • how to connect gitolite server with msysgit,
  • msysgit security,
  • msysgit and putty keygen tutorial,
  • msysgit needs password,
  • msysgit use id_rsa,
  • is msysgit secure,
  • msysgit authorized_keys,
  • msysgit and putty keygen tutorial,
  • msysgit without putty,
  • local ssh server windows msysgit,
  • mysysgit passphrase,
  • using putty with msysgit,
  • msysgit how to change login,
  • msysgit without password,
  • mysysgit firewall,
  • connect to linux server ssh msysgit,
  • log in as root msysgit,
  • msysgit ssh add,
  • msysgit .htaccess authentication,
  • msysgit secret key,
  • putty for linux ubuntu download,
  • msysgit use ppk,
  • how to change linux password of web server ubuntu by using putty,
  • Subscribe

    Find MMNCS.COM on Facebook, about guides, tutorials and learning within webdevelopment, drupal, MySQL, PHP, WordPress, SEO...
    Follow MMNCS.COM on Twitter and get the latest updates
    Follow @mmncs
    Subscribe to MMNCS.COM newsletter, about guides, tutorials and learning within webdevelopment, drupal, MySQL, PHP, WordPress, Programming, Technology, SEO...
  • The Best technology news guides tips tricks on the Internet
  • best online art gallery, paintings, illustrations, fine art photography
  • Services

    Check your Google PageRank checker optimize seo serp page rank
    Take a picture of any website, WordPress Screenshot demo
  • Latest

    Facebook Helps Breakup on One-Third of Marriages in the U.K.

    Facebook Helps Breakup on One-Third of Marriages in the U.K.

    December 30th, 2011

    Husbands and wives in the United Kingdom headed for divorce are increasingly citing Facebook in thei[...]

    Nokia Lumia 800 Demo of Skyscanner. Flight Deals Search for Windows Phone

    Nokia Lumia 800 Demo of Skyscanner. Flight Deals Search for Windows Phone

    December 30th, 2011

    Here's another awesome application for the Nokia Lumia 800 and other Windows Phones. Skyscanner allo[...]

    Nokia Lumia, Samsung, HTC rumored to announce LTE Windows Phone smartphones at CES

    Nokia Lumia, Samsung, HTC rumored to announce LTE Windows Phone smartphones at CES

    December 29th, 2011

    Rumor has it that the one thing that is notoriously missing (well, one of the things) from any Wind[...]

    Why I’m Replacing My iPhone With Nokia Lumia 800 And Why Android Is No Option

    Why I’m Replacing My iPhone With Nokia Lumia 800 And Why Android Is No Option

    December 7th, 2011

    Spoiler alert: This article is about how great the new Nokia Lumia 800 is, so if you are an iPho[...]

    Apple iPhone 4S Battery Drain Is Starting To Become A Serious Issue [iOs 5]

    Apple iPhone 4S Battery Drain Is Starting To Become A Serious Issue [iOs 5]

    November 29th, 2011

    Waiting on the next expected fix from Apple, iPhone 4S users complaining of rapid battery drain are [...]

  • musicfordriving com music for driving underground experimental electronic electronica dj rock jazz upcomming interesting music hot list hype
  • Selected

    Bill Gurley; Too Many Start-Ups Chase Too Little Cash

    Bill Gurley; Too Many Start-Ups Chase Too Little Cash

    November 14th, 2011

    Venture capitalist Bill Gurley has noticed something new this autumn: a big jump in the number of wh[...]

    The Best Programming Contest Ever Made – The AI Challenge Ants 2011 [Developer]

    The Best Programming Contest Ever Made - The AI Challenge Ants 2011 [Developer]

    October 30th, 2011

    The best programming contest ever made! Well that is what they state. The AI Challenge Ants 2011 is [...]

    Take A Picture Of Any Website [WordPress Screenshot Demo]

    Take A Picture Of Any Website [WordPress Screenshot Demo]

    October 28th, 2011

    Take a picture of any website. Just enter the website address in the form and press the button "Take[...]

    Optimize Your Time And Write Better CSS With {less} – [CSS Stylesheets]

    Optimize Your Time And Write Better CSS With {less} - [CSS Stylesheets]

    October 23rd, 2011

    If you think parts of CSS is repetitive, tedious, and … well, very boring. Have a look here. LESS [...]

    Call Your Friends For Free –  Cut The Expensive Voice And Text Plans To The Bare Minimum [Mobile Apps]

    Call Your Friends For Free - Cut The Expensive Voice And Text Plans To The Bare Minimum [Mobile Apps]

    October 14th, 2011

    After been using Viber for some time now. We highly recommend this mobile application for all smartp[...]

  • News

    Facebook Helps Breakup on One-Third of Marriages in the U.K.

    Facebook Helps Breakup on One-Third of Marriages in the U.K.

    December 30th, 2011

    Husbands and wives in the United Kingdom headed for divorce[...]

    Nokia Lumia 800 Demo of Skyscanner. Flight Deals Search for Windows Phone

    Nokia Lumia 800 Demo of Skyscanner. Flight Deals Search for Windows Phone

    December 30th, 2011

    Here's another awesome application for the Nokia Lumia 800 and[...]

    Nokia Lumia, Samsung, HTC rumored to announce LTE Windows Phone smartphones at CES

    Nokia Lumia, Samsung, HTC rumored to announce LTE Windows Phone smartphones at CES

    December 29th, 2011

    Rumor has it that the one thing that is notoriously missing[...]

  • Social Media

    Solved: Facebook XFBML Like Button Bug Creates a Vertical Scroll-Bar [Web Developer]

    Solved: Facebook XFBML Like Button Bug Creates a Vertical Scroll-Bar [Web Developer]

    September 16th, 2011

    After been doing a lot of work on the site I noticed when testing in IE8 and Firefox 3.6.x that I wa[...]

    Add a Cool Google Plus Profile Add to Circles Widget to Your Website [Google Plus]

    Add a Cool Google Plus Profile Add to Circles Widget to Your Website [Google Plus]

    August 11th, 2011

    Google Plus has created a very simple widget to embed your Google Plus profile on websites. This wid[...]

    How To Export All Your Facebook Friends To Google+ Using Yahoo Mail [Google+]

    How To Export All Your Facebook Friends To Google+ Using Yahoo Mail [Google+]

    August 8th, 2011

    Since the popular Chrome extension Facebook Friends Exporter got blocked we needed another way of ge[...]

  • Google

    Check Your Google Page Rank Here – Updated To Use The New Google PageRank Query URL

    Check Your Google Page Rank Here - Updated To Use The New Google PageRank Query URL

    October 8th, 2011

    Check PAGE RANK of Web site pages Instantly This is a free service to check Google™ page rank ins[...]

    Add a Simple Google Translate DropDown Box To Your Web Site [Tips & Tricks]

    Add a Simple Google Translate DropDown Box To Your Web Site [Tips & Tricks]

    September 6th, 2011

    Google Translate is the best free online translation service today and I often wonder why I rarely s[...]

    Google Closes Down 10 Mayor Business Areas [Tech News]

    Google Closes Down 10 Mayor Business Areas [Tech News]

    September 5th, 2011

    Google closes down 10 business areas in which the company itself calls "autumn-cleaning."The cle[...]

  • Home
  • About
  • Contact
  • Wollawonka
Copyright © MMNCS.COM is a site aimed at web developers, system engineers and designers offering tutorials and articles on technologies, skills and techniques to improve how you design and build websites. We cover Open Source recommendations, Linux Server guides, PHP, HTML, CSS, Drupal & WordPress Tutorials, Guides, Tips & Technology News.