簡體   English   中英

通過ssh在mac上連接到amazon aws linux服務器

[英]connecting to amazon aws linux server by ssh on mac

我創建了一個新密鑰對並將其下載到我的mac,然后使用該密鑰對和我的安全組設置一個新的Amazon Linux AMI服務器。 現在我需要將我下載的密鑰對.pem文件放在我的用戶文件夾中的.ssh文件中? 我無法創建名為“.ssh”的文件夾,但由於名稱。

我在哪里把密鑰對放在我的mac上? 然后需要從我的linux bash連接到服務器的chmods或其他命令? 我知道“ssh我的公共DNS”,但我應該注意其他權限或其他什么? 這是一個新手問題。 謝謝。

您需要將密鑰對放在{your home directory} / .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>

你也可以創建一個文件〜/ .ssh / config chmod it 644然后在里面你可以添加這樣的東西

host mybox-root
  Hostname [the IP or dns name]
  User root
  IdentityFile ~/.ssh/[your keypair here]

那你就可以做

$ ssh mybox-root

你會更容易登錄

您可以使用Java MindTerm連接到Macbook pro中的EC2服務器。 這個對我有用。 這里有更多的細節和一步一步的指示。

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

有人問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

C.修復權限:

chmod 600 ~/.ssh/authorized_keys

D.將AWS Key復制到該文件:

cp AWS_key.text ~sam/.ssh/authorized_keys

#在創建EC2實例時,您之前會保存此SSH密鑰

E.然后測試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.

希望這會有所幫助,一切順利。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM