2016-07-07 4 views
0

Ich versuche, meine Server einzuloggen Datei eine Bastion Host und meine Konfiguration werfen ist wie folgt:ssh nicht mit „-F“ Arbeit durch eine Bastion-Host anmelden

Host 10.10.10.1 
User ec2-user 
ProxyCommand ssh -W %h:%p xxx.xxx.xxx.xxx 
IdentityFile key.pem 

Host xxx.xxx.xxx.xxx 
User ec2-user 
IdentityFile key.pem 
ForwardAgent yes 

Es funktioniert gut, wenn ich sparen Diese Konfiguration in ~/.ssh mit dem Namen "config", was die Standardkonfigurationsdatei von ssh ist. Ich kann mit „ssh -v 10.10.10.1“ anmelden und die debuglog ist wie:

OpenSSH_6.9p1, LibreSSL 2.1.8 
debug1: Reading configuration data ~/.ssh/config 
debug1: /Users/twer/.ssh/config line 2: Applying options for 10.10.10.1 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 21: Applying options for * 
debug1: Executing proxy command: exec ssh -W 10.10.10.1:22 xxx.xxx.xxx.xxx 
debug1: permanently_drop_suid: 501 
debug1: key_load_public: No such file or directory 
debug1: identity file key.pem type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file key.pem-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_6.9 
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000 
debug1: Authenticating to 10.10.10.1:22 as 'ec2-user' 
... 

Aber wenn ich die Konfiguration irgendwo anders (löschen Sie die config in ~/.ssh) und melden Sie sich mit „ssh -v speichern -F ~/mysshconfig 10.10.10.1 ", Es ist fehlgeschlagen. das Debug-Protokoll ist:

OpenSSH_6.9p1, LibreSSL 2.1.8 
debug1: Reading configuration data ansible-ssh.conf 
debug1: ansible-ssh.conf line 1: Applying options for 10.10.10.1 
debug1: Executing proxy command: exec ssh -W 10.10.10.1:22 xxx.xxx.xxx.xxx 
debug1: permanently_drop_suid: 501 
debug1: key_load_public: No such file or directory 
debug1: identity file key.pem type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file key.pem-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_6.9 
Permission denied (publickey). 

Da ich will ansible verwenden, ich brauche eine sshconfig mit dieser Option „-f“ angeben.

Antwort

2

Schließlich habe ich herausgefunden, dass ich auch die Konfigurationsdatei im ProxyCommand angeben sollte, da es sich nicht um eine Standarddatei handelt. Die Konfiguration sollte so sein:

Host 10.10.10.1 
User ec2-user 
ProxyCommand ssh ssh -F mysshconfig -W %h:%p xxx.xxx.xxx.xxx 
IdentityFile key.pem 

Host xxx.xxx.xxx.xxx 
User ec2-user 
IdentityFile key.pem 
ForwardAgent yes 
0

Da sich Ihre Konfigurationsdatei an einem anderen Speicherort befindet, zeigt der relative Pfad zur Schlüsseldatei nicht mehr auf dieselbe Stelle, sodass Sie "keine solchen Dateifehler" erhalten, wenn ssh versucht, Ihre Schlüsseldatei zu lesen.

Verwenden Sie stattdessen einen absoluten Pfad: ändern Sie key.pem in ~/.ssh/key.pem.

+0

Danke, aber es ist kein Weg Problem.Ich habe es selbst herausgefunden. – hsc

Verwandte Themen