too many quotes in command, generating error

I am trying to go through a file with hostnames and access those hosts remotely an excute the following to get the uid of user on each of the boxes.. but i have so many quotes.. its not working.. I fudged with the \ before certain quotes, but that was unsuccessful too...

What am I missing?

ssh hostname `getent passwd | grep username | awk -F":" '{print ($3)}'`

ksh: syntax error at line 1 : `(' unexpected

Hin awk part is worng ,should be:

awk -F":" '{print $3}'

[host]
[/]
[root-128]:getent passwd | grep user | awk -F":" '{print ($3)}'
4022

[host]
[/]
[root-129]:getent passwd | grep user | awk -F":" '{print $3}'
4022

Well, good to know that both work.. i have always done it the first way.. However, I am still having an issue executing the command remotely because I need to put it in quotes to run the ssh remote command. or is there another way of doing it?

ssh host 'getent passwd | grep user | awk -F":" '{print $3}''
awk: syntax error near line 1
awk: illegal statement near line 1

In the last command, you are missing the last single quote.
But you don't need all the quotes. This works:

# ssh hostname grep adm /etc/passwd | awk -F":" '{print $3}'
4
#

The only command you need to execute remotely is the grep'ing of the username. That output then gets locally piped to awk.

Oh. Wow. A lot easier than I was making it all out to be! Thanks!