need help in arranging the alias

Hello Guys,

I have around 100 hosts setup as alias in my profile for easy sshing.

alias ada='ssh -Y username@da.domain.com'
alias ast='ssh -Y username@terix.domain.com'
alias bb1='ssh -X username@ggserver.ns.domain.com'
.
.
.
.

I now would like to use sshmenu software in which .sshmenu has following syntax.

---
  2 items:
  3 - profile:
  4   title: ada
  5   sshparams: -Y username@da.domain.com
  6   type: host
  7   geometry:
  8 - profile:
  9   title: ast
 10   sshparams: -Y username@terix.domain.com
 11   type: host
 12   geometry:
 13 - profile:
 14   title:bb1
 15   sshparams: -X username@ggserver.ns.domain.com
 16   type: host
 17   geometry:
 18 ..
 19 ..
  ..
and so on..

I'd like to convert all aliases in to this .sshmenu file

Is it possible with script? Please help.

Thanks

C:\cygwin\tmp>tr "=" " " <up.txt | tr -d "'" | gawk '{print "- profile:\n  title: "$2"\n  sshparams: "$4,$5}'
- profile:
  title: ada
  sshparams: -Y username@da.domain.com
- profile:
  title: ast
  sshparams: -Y username@terix.domain.com
- profile:
  title: bb1
  sshparams: -X username@ggserver.ns.domain.com

I change the = to a space to make the fields easier to deal with, and I delete the ' characters to save confusion later.
This could be redirected to a file by adding >out.txt at the end of command.

Is this what you are trying to do?

1 Like

hello Joeyg

This is pretty much what I wanted, thanks! really appreciate it

Only missing thing is below 2 fields whic are common for all titles.

  type: host
  geometry:

so the o/p for each profile has 4 lines for each title

- profile:
    title: ada
    sshparams: -Y username@da.domain.com
    type: host
    geometry:

:b:

C:\cygwin\tmp>tr "=" " " <up.txt | tr -d "'" | gawk '{print "- profile:\n  title: "$2"\n  sshparams: "$4,$5"\n  type: host\n  geometry:"}'
- profile:
  title: ada
  sshparams: -Y username@da.domain.com
  type: host
  geometry:
- profile:
  title: ast
  sshparams: -Y username@terix.domain.com
  type: host
  geometry:
- profile:
  title: bb1
  sshparams: -X username@ggserver.ns.domain.com
  type: host
  geometry:
1 Like

Awsome. thanks much! you saved me a lot of time.

have a nice day.