get static DNS from Mikrotik router and output in .ssh/config format with comment as username
#!/usr/bin/python3 | |
from tikapy import TikapyClient | |
from pprint import pprint | |
client = TikapyClient('192.168.74.1', 8728) | |
client.login('admin', 'banzai74') | |
res= client.talk(['/ip/dns/static/print']) | |
for key, value in res.items(): | |
if 'comment' in value: | |
# print("Host", value['name'], value['address'], value['comment']) | |
print("Host", value['name']) | |
print(" HostName", value['address']) | |
print(" User", value['comment']) | |
else: | |
# print(value['name'], value['address']) | |
print("Host", value['name']) | |
print(" HostName", value['address']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
then use this alias to build
.ssh/config
for fast SSH selection to different hosts. Usespeco
. Merges other hosts from~/.ssh/config_
alias sss='ssh $(~/getStaticDns.py > ~/.ssh/config ; cat ~/.ssh/config_ >> ~/.ssh/config ; chmod 600 ~/.ssh/config; (grep Host ~/.ssh/config | grep -v HostName | cut -d" " -f2 | sort) | sort | uniq | peco --prompt=:)'