Index: boto/ec2/keypair.py |
diff --git a/boto/ec2/keypair.py b/boto/ec2/keypair.py |
index d08e5ce3b4a362ac5d0b3d230a082e860fd5e176..65c95908b0d5cc129c1dac4fcab23b1333a9591b 100644 |
--- a/boto/ec2/keypair.py |
+++ b/boto/ec2/keypair.py |
@@ -76,12 +76,14 @@ class KeyPair(EC2Object): |
:return: True if successful. |
""" |
if self.material: |
+ directory_path = os.path.expanduser(directory_path) |
file_path = os.path.join(directory_path, '%s.pem' % self.name) |
if os.path.exists(file_path): |
raise BotoClientError('%s already exists, it will not be overwritten' % file_path) |
fp = open(file_path, 'wb') |
fp.write(self.material) |
fp.close() |
+ os.chmod(file_path, 0600) |
return True |
else: |
raise BotoClientError('KeyPair contains no material') |