I wish I had more details as to what kind of unwanted attention you are getting because I would advise you first to show him through your actions that whatever type of attention he is giving you is making you feel uncomfortable. If he is getting too close when you talk and invading your personal space, it’s okay to step back and put some space between you two. If he is asking you to do things you don’t feel comfortable with, you have the right to speak up and tell him you don’t feel comfortable. If he is touching you inappropriately, you need to tell him to stop. Excusing his actions for any reason won’t change the behavior. Sometimes we interact with each other and unknowingly cause discomfort with conversation, physical touch, or simply invading one’s personal space. Either way, it needs to be addressed at the time so the person—in this case your boss—knows their behavior needs to be corrected.
As far as being worried about losing your job, there are laws that prevent this from happening. But understand that no matter how direct, honest and kind you might be, there’s always a chance that your message won’t be received the right way. To prevent any type of backlash, documenting each occurrence and going to human resources or neutral parameters your job has set in place will protect all parties involved. It is an employer’s responsibility to create a safe workplace environment for every employee; if anyone, especially a supervisor, is making you feel uneasy, my advice is to address your supervisor, keep proper documentation and inform human resources. Stand up for yourself with confidence and set professional boundaries according to your comfort level.