1. Use PuTTY Key Generator to generate new keypair on Windoze machine.
2. Copy "Public key for pasting into OpenSSH authorized_keys file" that resides in the remote server at /.ssh/authorized_keys2
3. SSH into FreeBSD machine and run ssh-keygen -t dsa (to generate SSH-2 RSA keys) logged in as user you want to gain access to account. This also creates .ssh folder in user's ME with two files generated, i.e.:
$ pwd
/home/ME/.ssh
$ ls -la
total 8
drwx------ 2 ME ME 512 Feb 1 13:46 .
drwxr-xr-x 4 ME ME 512 Feb 1 13:46 ..
-rw------- 1 ME ME 1751 Feb 1 13:46 id_rsa
-rw-r--r-- 1 ME ME 404 Feb 1 13:46 id_rsa.pub
4. create public key file via $ vi myPUBkey.pub and then paste one line Public key that you copied earlier
5. ( OPTIONAL THOUGH NOT NECESSAY IN THIS CASE) --> On remote server convert public key to OpenSSH format:
$ ssh-keygen -i -f ~/.ssh/myPUBkey.pub > ~/.ssh/myPUBkey2.pub
6. Create authorized_keys file:
$ touch authorized_keys2 -> $ chmod 666 authorized_keys2
7. In .ssh folder cp (paste) myPUBkey2.pub generated into authorized_keys2 file:
cat ~/.ssh/myPUBkey2.pub >> ~/.ssh/authorized_keys2
8. $ chmod 600 authorized_keys2
9. Here is the entire process while shelled in:
$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/ME/.ssh/id_dsa):
Created directory '/home/ME/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ME/.ssh/id_dsa.
Your public key has been saved in /home/ME/.ssh/id_dsa.pub.
The key fingerprint is:
3D:56:D5:6H:45:BLAH BLAH BLAH ME@ME@web1.TESTSERVER.com
$ ls -la
total 22
drwxr-xr-x 3 ME ME 512 Feb 1 17:28 .
drwxr-xr-x 12 ME wheel 512 Jan 16 16:57 ..
-rw-r--r-- 1 ME ME 767 Jan 16 14:35 .cshrc
-rw-r--r-- 1 ME ME 248 Jan 16 14:35 .login
-rw-r--r-- 1 ME ME 158 Jan 16 14:35 .login_conf
-rw------- 1 ME ME 373 Jan 16 14:35 .mail_aliases
-rw-r--r-- 1 ME ME 331 Jan 16 14:35 .mailrc
-rw-r--r-- 1 ME ME 797 Jan 16 14:35 .profile
-rw------- 1 ME ME 276 Jan 16 14:35 .rhosts
-rw-r--r-- 1 ME ME 975 Jan 16 14:35 .shrc
drwxr-xr-x 6 ME ME 512 Feb 1 09:39 www
$ pwd
/usr/home/ME
$ cd
$ ls -la
total 24
drwxr-xr-x 4 ME wheel 512 Feb 1 17:30 .
drwxr-xr-x 12 ME wheel 512 Jan 16 16:57 ..
-rw-r--r-- 1 ME wheel 767 Nov 13 11:25 .cshrc
-rw-r--r-- 1 ME wheel 248 Nov 13 11:25 .login
-rw-r--r-- 1 ME wheel 158 Nov 13 11:25 .login_conf
-rw------- 1 ME wheel 373 Nov 13 11:25 .mail_aliases
-rw-r--r-- 1 ME wheel 331 Nov 13 11:25 .mailrc
-rw------- 1 ME wheel 0 Dec 6 13:35 .mysql_history
-rw-r--r-- 1 ME wheel 797 Nov 13 11:25 .profile
-rw------- 1 ME wheel 276 Nov 13 11:25 .rhosts
-rw-r--r-- 1 ME wheel 975 Nov 13 11:25 .shrc
drwx------ 2 ME wheel 512 Feb 1 17:29 .ssh
drwxr-xr-x 3 ME wheel 512 Jan 10 10:50 www
$ cd .ssh
$ ls -la
total 8
drwx------ 2 ME wheel 512 Feb 1 17:29 .
drwxr-xr-x 4 ME wheel 512 Feb 1 17:30 ..
-rw------- 1 ME wheel 1264 Feb 1 17:29 id_dsa
-rw-r--r-- 1 ME wheel 1126 Feb 1 17:29 id_dsa.pub
$ ~/.ssh/authorized_keys
/home/ME/.ssh/authorized_keys: not found
$ mkdir ~/.ssh/authorized_keys
$ ls -la
total 10
drwx------ 3 ME wheel 512 Feb 1 17:31 .
drwxr-xr-x 4 ME wheel 512 Feb 1 17:30 ..
drwxr-xr-x 2 ME wheel 512 Feb 1 17:31 authorized_keys
-rw------- 1 ME wheel 1264 Feb 1 17:29 id_dsa
-rw-r--r-- 1 ME wheel 1126 Feb 1 17:29 id_dsa.pub
$ vi rsa-key-20070201
ssh-rsa ENCRYPTED GOOBLE DI GOOP BLAH BLAH HIDDIE HO= rsa-key-20070201
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
rsa-key-20070201: new file: 1 lines, 226 characters
$ ls -la
total 12
drwx------ 3 ME wheel 512 Feb 1 17:32 .
drwxr-xr-x 4 ME wheel 512 Feb 1 17:30 ..
drwxr-xr-x 2 ME wheel 512 Feb 1 17:31 authorized_keys
-rw------- 1 ME wheel 1264 Feb 1 17:29 id_dsa
-rw-r--r-- 1 ME wheel 1126 Feb 1 17:29 id_dsa.pub
-rw-r--r-- 1 ME wheel 226 Feb 1 17:32 rsa-key-20070201
$ mkdir ~/.ssh/authorized_keys2
$ ls -la
total 14
drwx------ 4 ME wheel 512 Feb 1 17:33 .
drwxr-xr-x 4 ME wheel 512 Feb 1 17:30 ..
drwxr-xr-x 2 ME wheel 512 Feb 1 17:31 authorized_keys
drwxr-xr-x 2 ME wheel 512 Feb 1 17:33 authorized_keys2
-rw------- 1 ME wheel 1264 Feb 1 17:29 id_dsa
-rw-r--r-- 1 ME wheel 1126 Feb 1 17:29 id_dsa.pub
-rw-r--r-- 1 ME wheel 226 Feb 1 17:32 rsa-key-20070201
$ rm authorized_keys
rm: authorized_keys: is a directory
$ touch ~/.ssh/authorized_keys2
$ ls -la
total 14
drwx------ 4 ME wheel 512 Feb 1 17:33 .
drwxr-xr-x 4 ME wheel 512 Feb 1 17:30 ..
drwxr-xr-x 2 ME wheel 512 Feb 1 17:31 authorized_keys
drwxr-xr-x 2 ME wheel 512 Feb 1 17:34 authorized_keys2
-rw------- 1 ME wheel 1264 Feb 1 17:29 id_dsa
-rw-r--r-- 1 ME wheel 1126 Feb 1 17:29 id_dsa.pub
-rw-r--r-- 1 ME wheel 226 Feb 1 17:32 rsa-key-20070201
$ rm -r authorized_keys
$ rm -r authorized_keys2
$ touch ~/.ssh/authorized_keys2
$ ls -la
total 10
drwx------ 2 ME wheel 512 Feb 1 17:34 .
drwxr-xr-x 4 ME wheel 512 Feb 1 17:30 ..
-rw-r--r-- 1 ME wheel 0 Feb 1 17:34 authorized_keys2
-rw------- 1 ME wheel 1264 Feb 1 17:29 id_dsa
-rw-r--r-- 1 ME wheel 1126 Feb 1 17:29 id_dsa.pub
-rw-r--r-- 1 ME wheel 226 Feb 1 17:32 rsa-key-20070201
$ cat ~/.ssh/rsa-key-20070201 >> ~/.ssh/authorized_keys2
Thursday, February 01, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment