New to SSH keys

Status
Not open for further replies.

travalon

Explorer
Joined
Jan 6, 2013
Messages
82
Hello all,
I've finally figured out how to ssh into my NAS. I'mgetting really tired of putting my password in all the time so I figured how hard can keys be? For me pretty hard.
I followed this guide
http://technology.mattrude.com/2010/01/enable-ssh-no-password-authorization-with-freenas/
and checked it against this one
http://www.jonathanmoeller.com/screed/?p=3945

I failed.
heres what I do know:
My key is in a text document named authorized_keys in ~/.ssh on my NAS
I have pasted the private key into the proper box in ssh settings in the web gui.

what I don't know is:

where are my copies supposed to be on my client machine running linux mint?
I have a .ssh folder in my home directory and a ssh folder in my root directory.
Was I supposed to copy the part of the private key that contains
-----BEGIN DSA PRIVATE KEY-----
Proc-Type: xx,ENCRYPTED
DEK-Info: ***-***-***,*********************XX

AND -------------------------------end Private key----------------------

into the Host Private key box?

also when I copied from my public key to the authorized_keys file, was I supposed to copy everything or omit the "ssh-dss" on the first line?


I appreciate your help be cause Google has let me down and I can't seem to find anything here either.
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
Do a google search for "hak5 ssh keys", they have a few videos on setting up keys for beginners. Depending on the version of ssh, you may need to put your key(s) in authorized_keys2 in the .ssh directory.

I'm not sure, but this might be the first video in the series:

http://hak5.org/episodes/hak5-1109
 

travalon

Explorer
Joined
Jan 6, 2013
Messages
82
Ok so I've watched episodes 1108 through 1120 on Hak5 umpteen times. I took notes and got the keys generated and where they need to be.
I have pasted the public key in the public key box for my user. it starts with "ssh-rsa " and ends with my user@ my clientmachines name. Is this right?
On the server in .ssh I have the public key in the authorized_keys. It also begins and ends as stated above. again is this right?

On my client machine in .ssh I have my private key the .pub key and Known_hosts. Known_hosts has quite the string of data in one line.
I believe it is a hashed version of User@ host.domain then it says= ssh-rsa and the string of data/the key and nothing after that.

When I tried to ssh into the nas I got the fingerprint and checked it as good and it was permantly added to the known_hosts file.

Now when I try to ssh in I am always asked for my password. What did I do Wrong?

Thanks to all who look and even more so to those who help. +1
 

paleoN

Wizard
Joined
Apr 22, 2012
Messages
1,403
Now when I try to ssh in I am always asked for my password. What did I do Wrong?
You can use both SSH keys and password authentication.
 

travalon

Explorer
Joined
Jan 6, 2013
Messages
82
@ paleoN I know but I want/need to get thr keys working. I ditched Windoze because well you probably know and now I want to learn as much as possible about linux. So, keys.
Also, it is a nas and I am constantly moving large files around. I have found that If I ssh in and use the cli to move stuff it goes much much faster than if I mount the share and cut and paste. The second method is so slow I get a picture in my head of the file leaving the nas coming to the client machine then going back to the nas on another hard drive. It's crazy slow.

I just want to ssh in and not have to give a password on my own network.
 

travalon

Explorer
Joined
Jan 6, 2013
Messages
82
Ok from LQ here's a response that kinda worked for me.

Code:
###### DIRECTIONS FOR CREATING RSA KEY################

	Directions for creating the rsa key and making the two
 servers talk to each other without password.

	1st change directory into .ssh and check what files are there.

 		[rx30@rx30 ~]$ cd .ssh
		[rx30@rx30 .ssh]$ ls -l
		total 4
		-rw-r--r-- 1 rx30 group 2980 Jun 13 12:02 known_hosts

	2nd create the rsa key.

		[rx30@rx30 .ssh]$ ssh-keygen -t rsa -b 4096
		Generating public/private rsa key pair.
		Enter file in which to save the key (/usr/rx30/.ssh/id_rsa):
		Enter passphrase (empty for no passphrase):
		Enter same passphrase again:
		Your identification has been saved in /usr/rx30/.ssh/id_rsa.
		Your public key has been saved in /usr/rx30/.ssh/id_rsa.pub.
		The key fingerprint is:
		cb:b0:40:c6:e9:f4:9e:f5:71:fc:c3:00:c0:f7:c6:75 rx30@rx30.localdomain

	3rd check that there are two new files with the following permissions

		[rx30@rx30 .ssh]$ ls -l
		total 12
		-rw------- 1 rx30 group 3243 Jun 22 15:50 id_rsa
		-rw-r--r-- 1 rx30 group  743 Jun 22 15:50 id_rsa.pub
		-rw-r--r-- 1 rx30 group 2980 Jun 13 12:02 known_hosts
	
	4th change directory back to the users $HOME

		[rx30@rx30 .ssh]$ cd

	5th copy the key to the remote server

		[rx30@rx30 ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub rx30@***.***.***.***
		25
		rx30@***.***.***.***'s password:
		Now try logging into the machine, with "ssh 'rx30@***.***.***.***'", and check in:

		.ssh/authorized_keys

		to make sure we haven't added extra keys that you weren't expecting.

	6th, follow directions on the screen.

		[rx30@rx30 ~]$ ssh rx30@***.***.***.***
		Last login: Fri Jun 22 14:12:08 2012 from 10.10.4.77
		[rx30@rx30 ~]$ exit
		logout
		Connection to ***.***.***.*** closed.

##############################################################################################################################################


at 1 point towards the end (step 5) Ubuntu asked for the key password I assigned when generating it. This is when I set up key pairs on my htpc. It worked flawlessly.

On Freenas8 I am never asked for the password for the key. I have 2 ????'s.

1. My user, do I paste the public key I generated in the SSH Public Key Box? I did but it didn't seem to help.
2. Under services/SSH/Settings there's a "Host private Key" box. Do I need to put anything in there?
 
Status
Not open for further replies.
Top