2014年12月17日 星期三

amazon新增了一個instance之後,登入的方式(ubuntu為例)

在amazon ec2新增一個instance後
取得key以後 (pem file),如何登入該instance

(1) 首先要先取得該instance的public ip

如果是在windows上面的話
1. 用puttygen這個tool去產生 .ppk
2. 使用putty登入,登入的時候,除了輸入該instance的public ip外,要將剛剛產生的ppk檔案指定在Connection ->SSH->Auth->Private Key file for authentication中,然後記得使用"ubuntu"作登入

如果你是從別台linux主機連過去的話
1. 先將pem file傳送到你的linux主機目錄底下(ex. /tmp/)
2. chmod 400 xxxxxx.pem
3. sudo ssh -i xxxxxx.pem ubuntu@{your instance's public ip}


(2) 由於每次都要使用pem file登入實在有點小麻煩,改由password驗證的方法如下
1. 透過剛剛的方式,登入該instance
2. sudo vim /etc/ssh/sshd_config (將 PasswordAuthentication 參數由 no 改為 yes)
3. sudo service ssh restart (重新啟動ssh服務)


如果要回憶的話,可以參考下列文章: http://jex.logdown.com/posts/164678-amazon-ec2-free-programme-host-ssh-online