Before recent changes about portal key generation to own multiple keys of the same portal you had to drop the key of the aimed portal before hacking it.
Then, you had chances to gain a second portal, grab the dropped key
and you had two keys.
Now that portal keys are much rarest
when hacking, you can gain a key even if you were already carrying the same portal key, but you'll have to be patient and persistent.
Note that sometimes, when making a big XMP blast on an enemy resonator, a portal can drop a portal key (his key or a key of the linked portal).
EDIT January 2014 : since a few weeks, if you already hold a portal key, you have nearly 0% of chances to get another one.
To obtain a new key, drop the keys you own, then hack
and you'll probably get a new key (~80%)
gaming.stackexchange.com/users/18551/Cédric Julien
Wow, ok all these answers are super out of date.
Methods of obtaining multiple portal keys: Method
the first: Glyph Hacking
When you glyph hack, you can enter the More glyph into the Command Channel to request a key.
This makes a key a potential hack reward irrespective of how many keys are currently in your inventory.
Note that there is a chance that the portal will not give you a new key, just like if you hacked a portal with no key in your inventory.
Method
the second: Putting Keys in Capsules If you have a key inside a capsule (Blue Capsule/ MUFG /Quantum/Key Capsule)
you can hack another key from a portal.
This works for both standard hacking or glyph hacking with or without entering the More glyph.
Method
the third: Dropping keys If you drop a key you are holding (so that there are no un-capsuled keys in your inventory)
, you can hack another key from the portal.
As a side note, if a portal fracker is applied, it will double the hack output for all items including keys, which means that you can get 2 keys from one hack.
gaming.stackexchange.com/users/80115/JamesENL
They try.
And try again.
.I
doubt that there are any factors besides random chance involved.
One enemy portal which I hack at most twice daily has given me three keys during the last two weeks or so; I've got no keys from some others which I hack three times as often.
gaming.stackexchange.com/users/38682/Matthias Urlichs
Keys are issued randomly and the random chance of getting one fluctuates quite a bit at the moment as the game devs settle the tuning.
I'm getting lots of keys again now,
where is a two days ago I was getting nothing.
You can't 'normaly' carry two keys from the same portal in your inventory at the same time, but there is a workaround which I've read about (but not tried).
If you get a key, take it somewhere safe and "drop" it. go back to the same portal, and should you get another key you can keep it.
Go back to where you dropped the first one and pick it back up, you should (allegedly) have two keys for the same portal in your inventory.
^^^
That is nonsense.
I've now got multiple keys for portals in my inventory.
gaming.stackexchange.com/users/39394/Jim
Chances seem greater to hack an extra portal key when you "hide" the one in inventory in a capsule, if you are lucky enough to have one.
gaming.stackexchange.com/users/76121/Rusty
You can also put a key in a capsule and then hack it again.
I do this quite often.
gaming.stackexchange.com/users/87270/wilbur1776
I've been seeing people mention in chat that they have a bunch of copies of keys for the same portal.  How are they doing this?  I feel like I have a hard enough time getting one copy of a key for most portals.
How do I get multiple copies of the same portal key?
gaming.stackexchange.com
<ingress>
gaming.stackexchange.com/questions/98006
gaming.stackexchange.com/users/22491/mmrobins
When hacking, you gave the key for a portal even when you already have that key. Keys are issued randomly.  While it is possible to obtain the same key more than once, it comes down to random chance.
The community is suggesting few ways to get multiple copies of a portal key, based on random chance.