我创建了一个新密钥对并将其下载到我的mac,然后使用该密钥对和我的安全组设置一个新的Amazon Linux AMI服务器。现在我需要将我下载的密钥对.pem文件放在我的用户文件夹中的.ssh文件中?我无法创建名为“.ssh”的文件夹,但由于名称。
我在哪里将密钥对放在我的mac上?然后需要从我的linux bash连接到服务器的chmods或其他命令?我知道“ssh我的公共DNS”,但我应该注意其他权限或其他什么?这是一个新手问题。感谢。
答案 0 :(得分:74)
您希望将密钥对放在{您的主目录} / .ssh中。如果该文件夹不存在,请创建它。将密钥对放在那里后,您必须更改文件的权限,以便只有您的用户才能读取它。 启动终端并键入
chmod 600 $HOME/.ssh/<your keypair file>
这限制了对文件的访问,然后限制对文件夹类型的访问
chmod 700 $HOME/.ssh
您必须限制访问权限,因为OpenSSH协议不允许您使用其他人可以查看的密钥。
然后登录您的实例,从终端输入
ssh -i <your home directory>/.ssh/<your keypair file> ec2-user@<ec2 hostname>
答案 1 :(得分:64)
你也可以创建一个文件〜/ .ssh / config chmod它644 然后在里面你可以添加这样的东西
host mybox-root
Hostname [the IP or dns name]
User root
IdentityFile ~/.ssh/[your keypair here]
然后你可以做
$ ssh mybox-root
您将更容易登录。
答案 2 :(得分:1)
您可以使用Java MindTerm连接到Macbook pro中的EC2服务器。这个对我有用。这里有更多的细节和一步一步的指导。
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html
答案 3 :(得分:0)
http://www.openssh.com/是http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-connect-to-instance-linux.html#using-ssh-client(选项3)
的建议内容答案 4 :(得分:-1)
有人在Mac上询问创建〜/ .ssh文件夹的简单方法是运行命令ssh-keygen,然后使用以下设置......
一个。
macbook-air$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/sam/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/sam/.ssh/id_rsa.
Your public key has been saved in /Users/sam/.ssh/id_rsa.pub.
B中。然后创建:
touch ~/.ssh/authorized_keys
℃。修复权限:
chmod 600 ~/.ssh/authorized_keys
d。将AWS Key复制到该文件:
cp AWS_key.text ~sam/.ssh/authorized_keys
#在创建EC2实例
时,您之前会保存此SSH密钥电子。然后测试ssh到AWS Linux服务器 - 您将看到此错误:
ssh -i ./authorized_keys root@ec2-54-76-176-29.ap-southeast-2.compute.amazonaws.com
请以“ec2-user”用户身份登录,而不是以“root”用户身份登录。
F。重新尝试,它应该与允许的AWS用户“ec2-user”:
一起使用ssh -i ./authorized_keys ec2-user@ec2-54-76-176-29.ap-southeast-2.compute.amazonaws.com
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2014.09-release-notes/
9 package(s) needed for security, out of 12 available
Run "sudo yum update" to apply all updates.
希望这有所帮助,一切顺利。