Weitere ähnliche Inhalte
Ähnlich wie ssh_configのススメ (20)
ssh_configのススメ
- 7. つまり
$ ssh -p 2222 very-long-user-name@very-long-server-name.
example.com
これを
$ cat .ssh/config
Host very
Port 2222
User very-long-user-name
HostName very-long-server-name.example.com
$ ssh very
こうしておくと
こうなる
- 8. $ scp -P 2222 very-long-
user-name@very-long-
server-name.example.com:
hoge.txt ./
$ scp very:hoge.txt ./
$ rsync --port 2222 very-
long-user-name@very-long-
server-name.example.com:
hoge.txt ./
$ rsync very:hoge.txt ./
$ git clone ssh:
//very/hoge.git
$ git clone ssh://very-
long-user-name@very-long-
server-name.example.com:
2222/hoge.git
さらに
- 11. ssh_config初級編
Host hoge
Port 2222
User taro
HostName foobar.example.com
IdentityFile ~/.ssh/id_rsa_2
Host fuga
User jiro
HostName fuga.example.com
設定が適用されるホスト名
SSHサーバのポート番号(標準は22)
ログインユーザ名
実際に接続するホスト名orIPアドレス
認証用の秘密鍵ファイル
- 29. ssh_config上級編
Host host_machine,*
ProxyCommand ssh -W $(ssh host_machine virsh dumpxml
`echo %h | cut -d, -f2` | awk -F"[<']" '$2=="mac
address="{print $3}' | xargs -I@ ssh host_machine grep @
/var/lib/libvirt/dnsmasq/default.leases | awk '{print
$3}'):%p host_machine
- 30. ssh_config上級編
Host host_machine,*
ProxyCommand ssh -W $(ssh host_machine virsh dumpxml
`echo %h | cut -d, -f2` | awk -F"[<']" '$2=="mac
address="{print $3}' | xargs -I@ ssh host_machine grep @
/var/lib/libvirt/dnsmasq/default.leases | awk '{print
$3}'):%p host_machine
手元のマシン
host_machine
kvm, libvirt, dnsmasq
- 31. ssh_config上級編
Host host_machine,*
ProxyCommand ssh -W $(ssh host_machine virsh dumpxml
`echo %h | cut -d, -f2` | awk -F"[<']" '$2=="mac
address="{print $3}' | xargs -I@ ssh host_machine grep @
/var/lib/libvirt/dnsmasq/default.leases | awk '{print
$3}'):%p host_machine
手元のマシン
host_machine
kvm, libvirt, dnsmasq
vm1 vm2
- 32. ssh_config上級編
Host host_machine,*
ProxyCommand ssh -W $(ssh host_machine virsh dumpxml
`echo %h | cut -d, -f2` | awk -F"[<']" '$2=="mac
address="{print $3}' | xargs -I@ ssh host_machine grep @
/var/lib/libvirt/dnsmasq/default.leases | awk '{print
$3}'):%p host_machine
手元のマシン
host_machine
kvm, libvirt, dnsmasq
vm1 vm2
192.168.122.123 192.168.122.234
- 33. ssh_config上級編
Host host_machine,*
ProxyCommand ssh -W $(ssh host_machine virsh dumpxml
`echo %h | cut -d, -f2` | awk -F"[<']" '$2=="mac
address="{print $3}' | xargs -I@ ssh host_machine grep @
/var/lib/libvirt/dnsmasq/default.leases | awk '{print
$3}'):%p host_machine
手元のマシン
host_machine
ssh host_machine,vm1 ssh host_machine,vm2
kvm, libvirt, dnsmasq
vm1 vm2
192.168.122.123 192.168.122.234
- 34. ssh_config上級編
Host host_machine,*
ProxyCommand ssh -W $(ssh host_machine virsh dumpxml
`echo %h | cut -d, -f2` | awk -F"[<']" '$2=="mac
address="{print $3}' | xargs -I@ ssh host_machine grep @
/var/lib/libvirt/dnsmasq/default.leases | awk '{print
$3}'):%p host_machine
手元のマシン
host_machine
ssh host_machine,vm1 ssh host_machine,vm2
kvm, libvirt, dnsmasq
vm1 vm2
192.168.122.123 192.168.122.234
サーバ側の設定は一切不要!
クライアントの.ssh/configに
2行設定するだけ!
- 35. ssh_config上級編
Host host_machine,*
ProxyCommand ssh
-W $(
ssh host_machine
virsh dumpxml `echo %h | cut -d, -f2`
| awk -F"[<']" '$2=="mac address="{print $3}'
| xargs -I@ ssh host_machine
grep @ /var/lib/libvirt/dnsmasq/default.leases
| awk '{print $3}'
):%p
host_machine