Solved

Setup a SSH public key in linux

Posted on 2013-11-04
7
628 Views
Last Modified: 2013-11-23
Hi, I am new in Linux. Per this email :

anyone with Sudo privileges on a server  will have to login remotely with SSH public key authentication, instead of using a password.   I'd suggest you set up a public key soon.

Could you please help  me on this ? I need to set up a public key. I am using Putty for SSH connection.

Thanks
0
Comment
Question by:Golchehr
7 Comments
 
LVL 14

Expert Comment

by:comfortjeanius
ID: 39621881
You can check this link out to see if it helps.

Howto Linux / UNIX setup SSH with DSA public key authentication

If you want to use RSA instead DSA just type:

ssh-keygen -t rsa
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 39622196
ThomasMcA2 - I deleted your comment because it is known as a 'blind' link, just pointing to another site without any explanation or further details is not really helping.

http://support.experts-exchange.com/customer/portal/articles/1162518-using-off-site-content-on-experts-exchange

gerwinjansen
Topic Advisor
0
 
LVL 13

Expert Comment

by:Daniel Helgenberger
ID: 39622917
Hello roozbehdec,

to make a long story short: SSH keys are like the name says, like real keys - but a file. There are always two parts; your private key, which you need to keep secret and protected with a password, and your public key, which can be handed over to anyone. The trick: your key can encrypt a message which only the public key can decrypt and vice versa. This way, a host knows it is you (or at least your key).

In linux, there are basically these files:
ls -1 ~/.ssh
authorized_keys  # < this file holds public keys allowed to log in as this user on the local system, optional
config           # < this file holds general as well as host specific configs, optional
id_rsa           # < this is your private key! protect it well, mandatory
id_rsa.pub       # < your public key, the contents needs to be put authorized_keys of the remote host, optional
known_hosts      # < list of fingerprints of hots perilously connected to prevent man-in-the-middle-attacks, optional but commonly there

Open in new window


To generate your keys and create the keys and log in with ssh keys, open a command prompt on your local computer:
$ ssh-keygen       # interactively creates id_rsa and id_rsa.pub; RSA is the default here nowadays
$ ssh-copy-id username@reomtelinuxhost # enter your password; your public key gets copied in authorized_keys in 'username's home folder on the remote host; enter the password one last time
# now test things
$ ssh -t username@reomtelinuxhost # here you will need to enter the password for the key
$ and connect for real:
$ ssh username@reomtelinuxhost

Open in new window


Note, SSH with PKI is considered as very secure and should always be used with sensible accounts like root.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Accepted Solution

by:
Golchehr earned 0 total points
ID: 39657472
0
 

Author Comment

by:Golchehr
ID: 39657480
Those links helped me to solve my issue.
0
 

Author Comment

by:Golchehr
ID: 39657496
Please close this question.
0
 

Author Closing Comment

by:Golchehr
ID: 39671097
Those links helped me to solve my issue.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question