Sponsored Content
Special Forums UNIX and Linux Applications SSH: Avoiding password prompt with rsa key generation Post 302220440 by same1290 on Thursday 31st of July 2008 05:50:15 PM
Old 07-31-2008
SSH: Avoiding password prompt with rsa key generation

Hi,

I am using a remote storage service for backing up our data - we want to have a script run as part of a cron job which would do the backups from our local Linux machine to the service's Linux machine.

I want to use tar and ssh to do this (rather than mounting the disk and using cp) . Therefore want to learn how to avoid having to type in a password with ssh. I am new to this feature so I went online and read the procedure, downloaded and built OpenSSH and did the following:

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/homes/12/same/.ssh/id_rsa):
/homes/12/same/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /homes/12/same/.ssh/id_rsa.
Your public key has been saved in /homes/12/same/.ssh/id_rsa.pub.
The key fingerprint is:
27:a4:d4:63:35:62: ... same@dpdw

$ ssh-copy-id -i ~/.ssh/id_dsa.pub test3@remote.machine
test3@remote.machine''s password:
Now try logging into the machine, with "ssh 'test3@remote.machine'", and check in:

.ssh/authorized_keys

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

So at this point I'm expecting to be able to ssh into the remote machine and not be prompted for a password. Is this what should happen? As can be below seen I'm still prompted.

$ ssh 'test3@remote.machine'
test3@remote.machine's password:

Can someone please suggest a possible problem with what I'm doing that's preventing this from working?

Thanks in advance,
Sam
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP in Shell Script with RSA-KEY or password.

I am trying to SFTP to a couple sites. One has an RSA-KEY that was sent to me. Currently I am running that manually using WinSCP. I would like to set it up as a CRON process on our Linux host (Sun). Can I use the rsa-key they sent me in any directory or does it need to be placed in a specific... (2 Replies)
Discussion started by: alemat
2 Replies

2. Shell Programming and Scripting

automating RSA key pair generation

I want to automate the process of generating RSA keys. I want to remotley login to a linux machine from a windows maching without having to enter a password. For this I need to generate the RSA key pair. but I want to do this procedure on alot of linux machines. For which I was looking to automate... (2 Replies)
Discussion started by: lassimanji
2 Replies

3. AIX

Ssh installation error "RSA key generation failed"

While trying to upgrade ssh from v4.7 to v5.0 on AIX 5.3 TL9, I end up with the following error. Has anyone come across this? Note: openssl has been upgraded to 0.9.8.840 before this upgrade Bala (0 Replies)
Discussion started by: balaji_prk
0 Replies

4. AIX

While trying to do ssh without password, rsa key file is created as empty.

Hi i have aix 5.3 operating system, and i am trying to do ssh without passwd, when i tried to create a rsakey, it produces empty file as an output, how can solve that problem? why it is giving empty output file, i tried with different user, situation same,.i have restarted sshd server. .ssh... (2 Replies)
Discussion started by: nibiru78
2 Replies

5. Linux

SSH user equivalency still prompt for password

Hi All, I've followed the exact same steps of how to setup and enable SSH user equivalent including the right permission, but when I "ssh" it still prompts for password. Could you help to see what I did wrong? I appreciate any helps. :confused: server1.com:/u01/oracle RAC1 > mkdir... (2 Replies)
Discussion started by: Beginer0705
2 Replies

6. UNIX for Dummies Questions & Answers

SSH version of rlogin (ie without password prompt)

I have 3 Solaris 10 UNIX servers, the shadow and passwd file are all identical and are automatically sync every 5 minutes. A majority of the users do not have CLI access but rather use a menu. I currently have menu options that allows them to rlogin to another server and I need to have the... (1 Reply)
Discussion started by: creedonjm
1 Replies

7. Programming

Test SSH but do not return password prompt

Hello forum, I want to have a function to test for passwordless SSH setup. Pretty simple. However, what I'm finding difficult is to NOT return a password prompt to screen IF it's not in place. Here's the function: check_passwordless_ssh_working() #check passed parameter, assuming it is... (4 Replies)
Discussion started by: doonan_79
4 Replies

8. UNIX for Advanced & Expert Users

Need Password-Less ssh with RSA-VPN

We have RSA SecureID softtoken key generator on my Windows machine. It generates new keys every 1 minute. Any HPUX server (be it ServerD or ServerP) requires my ID and the randomly generated RSA SecureID softtoken key from my Windows to login. I login to ServerD. Then I run a script... (0 Replies)
Discussion started by: mohtashims
0 Replies

9. UNIX for Dummies Questions & Answers

[SSH-RSA] Still prompting for password after generating keys

Hello, I'm trying to perform these operations without entering any password, as user "fzd":fzd@machine1> scp /tmp/srcFile1 fzd@machine2:/tmp/$destFile fzd@machine1> scp fzd@machine2:/tmp/$srcFile /tmp/$destFilebut alsofzd@machine1> scp /tmp/srcFile1 machine2:/tmp/$destFile fzd@machine1> scp... (6 Replies)
Discussion started by: fzd
6 Replies

10. Red Hat

Sudo Password Prompt over SSH

I am not sure what I am missing here. I have the following identical entry in /etc/sudoers on multiple Red Hat 6.4 servers. icinga ALL=NOPASSWD:/usr/bin/yum --security --exclude\="kernel*" check-update On one server when I enter the command over SSH as follows it works fine. ssh -t -q... (1 Reply)
Discussion started by: scotbuff
1 Replies
SSH(3pm)						User Contributed Perl Documentation						  SSH(3pm)

NAME
Net::SSH - Perl extension for secure shell SYNOPSIS
use Net::SSH qw(ssh issh sshopen2 sshopen3); ssh('user@hostname', $command); issh('user@hostname', $command); ssh_cmd('user@hostname', $command); ssh_cmd( { user => 'user', host => 'host.name', command => 'command', args => [ '-arg1', '-arg2' ], stdin_string => "string ", } ); sshopen2('user@hostname', $reader, $writer, $command); sshopen3('user@hostname', $writer, $reader, $error, $command); DESCRIPTION
Simple wrappers around ssh commands. For an all-perl implementation that does not require the system ssh command, see Net::SSH::Perl instead. SUBROUTINES
ssh [USER@]HOST, COMMAND [, ARGS ... ] Calls ssh in batch mode. issh [USER@]HOST, COMMAND [, ARGS ... ] Prints the ssh command to be executed, waits for the user to confirm, and (optionally) executes the command. ssh_cmd [USER@]HOST, COMMAND [, ARGS ... ] ssh_cmd OPTIONS_HASHREF Calls ssh in batch mode. Throws a fatal error if data occurs on the command's STDERR. Returns any data from the command's STDOUT. If using the hashref-style of passing arguments, possible keys are: user (optional) host (requried) command (required) args (optional, arrayref) stdin_string (optional) - written to the command's STDIN sshopen2 [USER@]HOST, READER, WRITER, COMMAND [, ARGS ... ] Connects the supplied filehandles to the ssh process (in batch mode). sshopen3 HOST, WRITER, READER, ERROR, COMMAND [, ARGS ... ] Connects the supplied filehandles to the ssh process (in batch mode). EXAMPLE
use Net::SSH qw(sshopen2); use strict; my $user = "username"; my $host = "hostname"; my $cmd = "command"; sshopen2("$user@$host", *READER, *WRITER, "$cmd") || die "ssh: $!"; while (<READER>) { chomp(); print "$_ "; } close(READER); close(WRITER); FREQUENTLY ASKED QUESTIONS
Q: How do you supply a password to connect with ssh within a perl script using the Net::SSH module? A: You don't (at least not with this module). Use RSA or DSA keys. See the quick help in the next section and the ssh-keygen(1) manpage. A #2: See Net::SSH::Expect instead. Q: My script is "leaking" ssh processes. A: See "How do I avoid zombies on a Unix system" in perlfaq8, IPC::Open2, IPC::Open3 and "waitpid" in perlfunc. GENERATING AND USING SSH KEYS
1 Generate keys Type: ssh-keygen -t rsa And do not enter a passphrase unless you wanted to be prompted for one during file copying. Here is what you will see: $ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/User/.ssh/id_rsa): 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: 5a:cd:2b:0a:cd:d9:15:85:26:79:40:0c:55:2a:f4:23 User@JEFF-CPU 2 Copy public to machines you want to upload to "id_rsa.pub" is your public key. Copy it to "~/.ssh" on target machine. Put a copy of the public key file on each machine you want to log into. Name the copy "authorized_keys" (some implementations name this file "authorized_keys2") Then type: chmod 600 authorized_keys Then make sure your home dir on the remote machine is not group or world writeable. AUTHORS
Ivan Kohler <ivan-netssh_pod@420.am> Assistance wanted - this module could really use a maintainer with enough time to at least review and apply more patches. Or the module should just be deprecated in favor of Net::SSH::Expect or made into an ::Any style compatibility wrapper that uses whatver implementation is avaialble (Net::SSH2, Net::SSH::Perl or shelling out like the module does now). Please email Ivan if you are interested in helping. John Harrison <japh@in-ta.net> contributed an example for the documentation. Martin Langhoff <martin@cwa.co.nz> contributed the ssh_cmd command, and Jeff Finucane <jeff@cmh.net> updated it and took care of the 0.04 release. Anthony Awtrey <tony@awtrey.com> contributed a fix for those still using OpenSSH v1. Thanks to terrence brannon <tbone@directsynergy.com> for the documentation in the GENERATING AND USING SSH KEYS section. COPYRIGHT
Copyright (c) 2004 Ivan Kohler. Copyright (c) 2007-2008 Freeside Internet Services, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. BUGS
Not OO. Look at IPC::Session (also fsh, well now the native SSH "master mode" stuff) SEE ALSO
For a perl implementation that does not require the system ssh command, see Net::SSH::Perl instead. For a wrapper version that allows you to use passwords, see Net::SSH::Expect instead. For another non-forking version that uses the libssh2 library, see Net::SSH2. For a way to execute remote Perl code over an ssh connection see IPC::PerlSSH. ssh-keygen(1), ssh(1), IO::File, IPC::Open2, IPC::Open3 perl v5.10.0 2008-05-14 SSH(3pm)
All times are GMT -4. The time now is 05:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy