ssh-keygen questions (not working)


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users ssh-keygen questions (not working)
# 8  
Old 08-23-2007
ssh-keygen questions (not working)

Ok. The program still is not working. It still is asking for a password. The funny thing is when I use 'ssh dwebapp1' at the command line it will show 'source user@remote host'

<<source>>
#!usr/bin/ksh

hostname=dwebapp1
login_name=clport

# password=

if [ -n `ssh $login_name@$hostname 'ls test/testfile.txt 2>/dev/null'` ]; then

echo file exists
else
echo "file doesn't exist";
fi

<<output>>
$ ksh file_exists.ksh
clport@dwebapp1's password:
file exists
# 9  
Old 08-23-2007
ssh-keygen questions (not working) --> resolved

OK. It does pay to know which ssh you are using.

$ ssh -V
OpenSSH_3.6.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090605f

this pointed me to the proper syntax for using private/public keys and ssh

public/private passwordless keys using: ksh and OpenSSH

This process allows an ssh connection between 2 servers without command-line authentication and run commands via a program.

From the server you will be connecting from: create a key pair:

ssh-keygen -t rsa #note: I did not use passphrase - just hit ‘enter'

<<output to screen>>
Generating public/private rsa key pair.
Enter file in which to save the key (/home/WebARCH/ol_inv/.ssh/id_rsa):
Created directory '/home/WebARCH/ol_inv/.ssh'.
Enter passphrase (empty for no passphrase): <press enter key and bypass>
Enter same passphrase again: <press enter key and bypass>
Your identification has been saved in /home/djm/.ssh/id_rsa.
Your public key has been saved in /home/djm/.ssh/id_rsa.pub.
The key fingerprint is:
3c:7e:41:2c:d2:51:f8:0b:ef:78:e7:e3:22:eb:af:6a ol_inv@dpbmdb2

Once you have generated a key pair, you must now install the public key on the server that you wish to log into. The public portion is stored in the file with the extension .pub in an ASCII encoding. Note: it is all one continuous line without line breaks.

Now you need to move that public key to the remote server paying close attention to file permissions. UNIX is very particular when it comes to file permissions. In order for the private key (resides on the source server ‘.ssh/id_rsa' to be recognized there cannot be any permissions for group or other, just for user:

-rw------- 1 ol_inv whs 883 Aug 23 09:26 id_rsa

To enable public key authentication on a server, you need to append the public portion of the key to the/.ssh/authorized_keys file. This may be accomplished with the following command-line:

ssh dwebapp1 "umask 077; cat >> .ssh/authorized_keys" </.ssh/id_rsa.pub
^^^^^^^^ ^^^^^^^^^^^^
Remote server Source server

The restrictive umask is required because the server will refuse to read/.ssh/authorized_keys files which have loose permissions. Once the public key is installed on the server, you should now be able to authenticate using your private key

Test your keys:

ssh username@host
If you do not see your remote server's splash page and you see the following page:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '/usr/local/ol_inv/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /usr/local/ol_inv/.ssh/id_rsa
Enter passphrase for key '/usr/local/ol_inv/.ssh/id_rsa':

Then you need to go back and check the permissions on the source server where the private key resides: id_rsa


After you correct your permissions on that file:

chmod 700 id_rsa

Try again:

ssh remoteuser@remoteserver


Note: replace remoteuser with actual user name on remote server
replace remoteserver with actual remote server name
# 10  
Old 08-23-2007
ssh-keygen questions (not working) --> resolved

also if when trying to ssh into the remote server and you are prompted for that server's password then the keys are not set up correctly. When attempting to ssh into the server it should automatically give you the remote server's splash screen.

if you are simply prompted for a password then check the file permissions for authorized_keys on the remote server. Those permissions must be:

chmod 644
# 11  
Old 09-01-2008
Hi Tekline Can you pls help me in making this work? I'm facing the same problem as the server prompts for the password everytime.

Steps in Detail:
--------------
Source Machine: SRC_Machine
Remote Mahcine: RMT_Machine

I logged on to SRC_Machine
ssh -V
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003

and generated a Key as shown below..
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/.ssh/id_rsa): /home/.ssh/id_rsa_test
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/.ssh/id_rsa_test.
Your public key has been saved in /home/.ssh/id_rsa_test.pub.
The key fingerprint is:
b6:74:7f:84:6f:21:68:fb:86:5c:2f:03:79:c9:ff:61

Modified the permision of the private key file to
chmod 600 id_rsa_test
-rwx------ 1 951 Sep 2 13:09 id_rsa_test

Then i did to appen the public key to Authorized Keys
ssh RMT_Machine "umask 077; cat >> .ssh/authorized_keys" < /home/.ssh/id_rsa_test.pub

chmod 700 id_rsa_test

Now while i do ssh username@RMT_Machine
it prompts me for the password.

Let me know if i'm missing any steps.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ssh-keygen problems

For some reason, when I try copying my public key to the server, despite it showing as being successful: rob@linux044:~$ ssh-copy-id -i /home/rob/Work/Keys/keys.txt.pub !@#$%.com /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/rob/Work/Keys/keys.txt.pub"... (7 Replies)
Discussion started by: Circuits
7 Replies

2. Cybersecurity

What makes up ssh-keygen keys?

When using ssh-keygen what does it look at to build the ssh keys? (1 Reply)
Discussion started by: toor13
1 Replies

3. UNIX for Dummies Questions & Answers

auto login not working after ssh-keygen

Hi, I have a generic id say "abc". In a client i logged into using this generic id and generated the key for autologin to do ssh to a server. I have kept the key in authorized_keys file in the server under the home directory of this generic id. (/u/abc/.ssh/authorized_keys) when i do... (7 Replies)
Discussion started by: rbalaj16
7 Replies

4. Shell Programming and Scripting

sftp ssh-keygen

sftp username@host <<EOF lcd /home/dirA cd /home/dirB mput *.txt exit EOF Hi, i have done the keygen-ssh settings but rite now I log through putty I enter my credentials and then when i successfully log in, then I issue the command ssh server name then I again enter into the server but... (1 Reply)
Discussion started by: rahulsxn660
1 Replies

5. UNIX for Dummies Questions & Answers

ssh-keygen error

Hi, I using ssh-keygen for passwordless authenciation firstly and I am following these steps mentioned below... 1) Login to pngpcdb1 using your user/pass 2) type 'bash' (without quotes) 3) ssh-keygen #generates private and public key. 4) copy this private key to the location of your sftp... (1 Reply)
Discussion started by: karan2597
1 Replies

6. UNIX for Dummies Questions & Answers

keygen-ssh

Hi, I was going thruough the password less authentication of keygen-ssh that will help us in generating keys...One thing that is not clear to me that if in nearby future we conncet to remote ftp server in that case now we need to only provide the user id itself that is password would not be... (1 Reply)
Discussion started by: rahul125
1 Replies

7. UNIX for Dummies Questions & Answers

ssh-keygen

Hi, I am new to unix, recently i was exploring password less remote connection to the ftp server and in that I was exploring the ssh-keygen utility, that it generates private & public keys that helps in transmitting files in encrypted format.Could you please explain me in detail about the... (1 Reply)
Discussion started by: rahul125
1 Replies

8. Shell Programming and Scripting

Query regarding ssh keygen

Hi, I have two Unix servers A and B. I have a script in server A. I want to connect to server B from A using ssh only and without giving passwords everytime i connect. I went through other posts regarding this and I generated a public key in server A and copied that in server B. Now when I... (3 Replies)
Discussion started by: mick_000
3 Replies

9. UNIX for Advanced & Expert Users

ssh-keygen stops working

Hey guys, I was using ssh-keygen settings for a long time to login on remote machines without password. 2 days back it suddenly stops working, i tried by reset all ssh-keygen setting but it not works. what could be the reason of this issue and how can i resolve this? (2 Replies)
Discussion started by: RohitKJ
2 Replies

10. Shell Programming and Scripting

SSH-Keygen script

Hello friends, I wanna to make new script which work as i defined below (1) it connect (using ssh) to remote server (2) remote server having passphrase key with password (3) Generate new passphrase on local machine with random 8 character password. (4) It will atomatically uploaded to... (4 Replies)
Discussion started by: jagnikam
4 Replies
Login or Register to Ask a Question