It's an interesting use of
Expect, but ssh can be configured
to log in without the password prompt, which may be more
appealing from a security standpoint because you get key-level
authentication instead of a simple password.
Of course,
OpenSSH
and
SSH act differently
with regards to configuration. Look in the man page for
references to "authorized_keys" for more info.
This is a little off-topic, but here is how SSH-SSH (for
lack of a better term) operates.
With SSH2, on server A, you would have a file like:
~/.ssh2/identification
----------------------
IdKey id_dsa_1024_a
On server B, where you want to connect with no password:
~/.ssh2/authorization
----------------------
Key id_dsa_1024_a.pub
You would copy the "id_dsa_1024_a.pub" key from server A
over to server B and put it in ~/.ssh2/
ObPerl:
Just for kicks, here's a Quick Hack that I put together
to schlep keys around from one box to several others.
#!/usr/bin/perl
#
# ssh-addauth - Adds automatic login to a remote SSH server
# from the current machine.
use strict;
use Sys::Hostname;
my ($default_key) = "id_dsa_1024_a.pub";
# These parameters may come from: /etc/ssh2/ssh2_config
my ($ssh_dir) = ".ssh2"; # UserConfigDirectory
my ($ssh_authfile) = "authorization"; # AuthorizationFile
my ($hostname) = hostname();
my ($username) = getpwuid($<);
foreach my $arg (@ARGV)
{
AddAuth($arg);
}
sub AddAuth
{
my ($remote_host) = @_;
system ("scp $ENV{HOME}/$ssh_dir/$default_key $remote_host:$ss
+h_dir/${username}_${hostname}_dsa_1024.pub");
system ("ssh $remote_host \"echo 'Key ${username}_${hostname}_
+dsa_1024.pub' >> $ssh_dir/$ssh_authfile\"");
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.