Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]13081[/thread]

Eigene ssh_config in Net::SFTP verwenden

Leser: 5


<< >> 7 Einträge, 1 Seite
GwenDragon
 2009-01-30 18:36
#118524 #118524
User since
2005-01-17
14510 Artikel
Admin1
[Homepage]
user image
Gast+2009-01-30 14:29:17--
ssh -F <homedir>/ssh_config <user@hostname> mache, klappt die Verbindung.

Deine Datei sollte dann aber config heißen und im Verzeichnis .ssh liegen!
Steht doch auch im man ssh drin!
Quote
-F configfile
Specifies an alternative per-user configuration file. If a configuration file is given on the command line, the system-wide configuration file (/etc/ssh/ssh_config) will be ignored. The default for the per-user configuration file is ~/.ssh/config.

Letzte Zeile ds o. g.: per-user configuration file is ~/.ssh/config

Es liest $ssh->config auch Konfigurationsdaten ein:
Quote
$ssh->config

Returns the Net::SSH::Perl::Config object managing the configuration data for this SSH object. This is constructed from data passed in to the constructor new (see above), merged with data read from the user and system configuration files.


Ist auch im Code drin:
Code: (dl )
1
2
    my $user_config = delete $arg{user_config} || "$ENV{HOME}/.ssh/config";
my $sys_config = delete $arg{sys_config} || "/etc/ssh_config";


Siehe auch in CPAN:Net::SSH::Perl::Config unter $cfg->read_config($file)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

Gast Gast
 2009-01-30 13:33
#118527 #118527
Hallo zusammen,

ich möchte gerne mit Net::SFTP eine Verbindung zu einem anderen Unix-Server aufmachen. Leider habe ich keinen Zugriff auf /etc/ssh_config:

Code: (dl )
Can't write to /etc/ssh_known_hosts: Permission denied at /usr/local/perl/5.8.6/lib/site_perl/5.8.6/Net/SSH/Perl.pm line 372


Somit möchte ich der Verbindung gerne eine ssh_config aus meinem Home-Dir mitgeben. Geht das?

Viele Grüße,
Jens
GwenDragon
 2009-01-30 13:47
#118528 #118528
User since
2005-01-17
14510 Artikel
Admin1
[Homepage]
user image
Normalerweise ist im verzeichnis ~/.ssh/ die Konfiguration für SSH zu speichern.

Da CPAN:Net-SFTP stammt von CPAN:Net-SSH-Perl ab und dieses liest aus der globalen und lokalen Konfiguration.

Vermutung:
Lege doch erst mal bitte eine lokale Konfiguration für SSH an und teste es mal.


http://www.pro-linux.de/t_netzwerk/ssh.html
http://linux.die.net/man/1/ssh
http://linux.die.net/man/5/ssh_config
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

Gast Gast
 2009-01-30 15:29
#118532 #118532
Hi,

wenn ich den Aufruf ohne Perl (also direkt unter Unix) mit

ssh -F <homedir>/ssh_config <user@hostname> mache, klappt die Verbindung. Ich möchte diese ssh_config aber gerne auch für Net::SFTP nutzen, weiss aber nicht, wie ich das in meinem Programm schreiben kann.

Grüße
Gast Gast
 2009-02-03 15:28
#118621 #118621
Hi,

ich krieg es nicht auf die Reihe :-/.

Code: (dl )
1
2
3
4
5
my $sshConf = Net::SSH::Perl::Config->new("1.1.1.1", options => [  ]);
my $hostKey = $sshConf->set("user_known_hosts", "/home/jz/.ssh/ssh_known_hosts");
$sshConf->read_config( '/home/jz/.ssh/config' );
my $ssh = Net::SSH::Perl->new("1.1.1.1");
my $cfg = $ssh->config();


Wenn ich ein Data::Dumper auf $sshConf mache, steht die geänderte user_known_hosts drin, wenn ich einen Dumper auf $ssg mache nach der letzten Zuweisung, steht wieder das Original unter /etc drin...
GwenDragon
 2009-02-03 16:12
#118622 #118622
User since
2005-01-17
14510 Artikel
Admin1
[Homepage]
user image
Mal ins Blaue gelesen, wohl die falsche Reihenfolge bzw. falsches Konfigurationsobjekt.
$ssh->config liest ja die Konfiguration zum erzeugten Objekt ein.
Du musst dann danach die eigenen Werte setzen.

Code: (dl )
1
2
3
4
5
my $ssh = Net::SSH::Perl->new("1.1.1.1");                 
my $cfg = $ssh->config(); # holt erst einmal lokale und globale Konfig

my $hostKey = $cfg->set("user_known_hosts", "/home/jz/.ssh/ssh_known_hosts"); # setzt eigene user_known_hosts
$cfg->read_config( '/home/jz/.ssh/config' ); # liest eigene config ein
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

Gast Gast
 2009-02-04 09:58
#118633 #118633
Die Verbindung über SSH scheint jetzt zu funktionieren, zumindest bekomme ich bei

Code: (dl )
1
2
print ssh->sock();
print ssh->session_id();


einen Rückgabewert.


Bei Net:SFTP klappt es leider noch nicht, da werden die Konfigurationen wohl in der falschen Reihenfolge gezogen:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
adeccmas: Reading configuration data /home/jz/.ssh/config
adeccmas: Reading configuration data /etc/ssh_config
adeccmas: Connecting to 1.1.1.1, port 22.
adeccmas: Remote protocol version 2.0, remote software version OpenSSH_5.0
adeccmas: Net::SSH::Perl Version 1.32, protocol version 2.0.
adeccmas: No compat match: OpenSSH_5.0.
adeccmas: Connection established.
adeccmas: Sent key-exchange init (KEXINIT), wait response.
adeccmas: Algorithms, c->s: blowfish-cbc hmac-sha1 none
adeccmas: Algorithms, s->c: blowfish-cbc hmac-sha1 none
adeccmas: Entering Diffie-Hellman Group 1 key exchange.
adeccmas: Sent DH public key, waiting for reply.
adeccmas: Received host key, type 'ssh-dss'.
adeccmas: Permanently added '1.1.1.1' to the list of known hosts.
Can't write to /etc/ssh_known_hosts: Permission denied at /usr/local/perl/5.8.6/lib/site_perl/5.8.6/Net/SSH/Perl.pm line 372


Hast du da evtl. noch einen Rat?
<< >> 7 Einträge, 1 Seite



View all threads created 2009-01-30 13:33.