このSSH構成があります。
Host git.domain.net
Port 22
Host *.domain.net
Port 2121
Host bastion
HostName nx4201.domain.net
User dummy
Host project_production
HostName nx4242.domain.net
User project
私はUbuntu 15.10を使用しており、ssh project_production
ポート2121を使用してnx4242.domain.netに接続しています。
Ubuntu 16.04を新しくインストールし、同じ設定ファイルを再インポートしました(個人のGitリポジトリからバージョン管理を受けていました)。
もう動作しません。
$ ssh -vvv project_production
OpenSSH_7.2p2 Ubuntu-4ubuntu1, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /home/sullivan/.ssh/config
debug1: /home/sullivan/.ssh/config line 12: Applying options for project_production
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "nx4242.domain.net" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to nx4242.domain.net [178.170.104.70] port 22.
ご覧のとおり、sshはポートに接続しようとしますが、ルールは22
気にしません。*.domain.net
各ホストにポートを割り当てることができることを知っていますが、ホストが多いです。
今は動作しませんが、古いシステムではなぜ動作しませんか?どうすれば修正できますか?
ちなみに、システムSSH構成ファイルは次のとおりです。
Host *
# ForwardAgent no
# ForwardX11 no
# ForwardX11Trusted yes
# RhostsRSAAuthentication no
# RSAAuthentication yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# IdentityFile ~/.ssh/id_ecdsa
# IdentityFile ~/.ssh/id_ed25519
# Port 22
# Protocol 2
# Cipher 3des
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
# MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
# RekeyLimit 1G 1h
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
SSHバージョン:
$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu1, OpenSSL 1.0.2g 1 Mar 2016
ベストアンサー1
私はついにここで答えを見つけました。https://superuser.com/a/1024928/650657
簡単に言えば、次の行を追加する必要があります。
CanonicalizeHostname yes
Host *.mydomain.com
User myusername
Host host1
HostName host1.mydomain.com
このように構成ファイルが再解析されます。
CanonicalizeHostname
奇妙なことは、以前はこのオプションを使用する必要がなかったことです。