There are two layers to this answer:
1) Before you even get a job offer, it's important to decide what your "walk away" number is (I called this Minimum Acceptable Salary). Having this number decided—and I recommend literally writing it down—before you get the offer helps you answer this question directly: You should negotiate hard enough to at least see if they will meet your walk away number. If they can't, you can walk away knowing it wasn't a good fit for you.
2) Once you're beyond your "walk away" number—meaning you'll definitely take the job and you're just trying to get the best compensation package possible before you start—things are pretty straightforward. You basically start by counter offering on base salary to see what they can do. Then look for opportunities to negotiate other things that are important to you (paid vacation time, signing bonus, RSUs, etc.).
When you negotiate salary, it should look more like a conversation about the small details than a pound-your-fist-on-the-table-and-shout-at-each-other-until-someone-relents type of negotiation.
"I'd be more comfortable at $X."
"We can't do $X, but can we do $Y."
"Ok, thanks for working with me. I was hoping to get $X, and I understand you can't meet me all the way. Can you do $Y plus an extra week of paid vacation?"
...
It's a collaborative back-and-forth and both of you should feel like you're just discussing details, not fighting over salaries.