ec2ssh가 편리해서 사용했어요.

2513 단어 AWSEC2ec2sshtech

ec2ssh가 편리해서 사용했어요.


전직 후 업무상 EC2를 접하는 일이 이전보다 많아졌다.
ssh의 기회가 증가했고 실례가 증가함에 따라 config 파일에 EC2의 호스트 이름을 추가하는 것은 비교적 번거로워졌다.
매번 증가할 때마다 config를 추가하면 좋겠지만 컨트롤러를 열고 복사해서 config 파일에 붙여넣으면 가능한 한 이런 작업을 하지 않으려고 했을 때ec2ssh를 발견할 수 있습니다.
https://github.com/mirakui/ec2ssh
ec2ssh는 EC2의 ssh입니다.저는 config 매니저입니다.
ec2ssh 명령을 사용하면 실례 이름 탭을 가져오고 공공 DNS를 호스트 이름으로 설정할 수 있습니다.

사용법


1. Name 태그를 인스턴스로 설정
실례의 Name 탭에 알기 쉬운 이름을 설정하십시오.
2. ~/.aws/credentials에 기재
# ~/.aws/credentials

[default]
aws_access_key_id=...
aws_secret_access_key=...

[myprofile]
aws_access_key_id=...
aws_secret_access_key=...
3. 설치ec2ssh
$ gem install ec2ssh
4. 초기화
$ ec2ssh init
5. 생기다편집ec2ssh
$ vim ~/.ec2ssh
---

path '/Users/koya.suzuki/.ssh/config'
profiles 'default' # ここはcredentialsに追加したユーザーを自由に設定できます
regions ENV['AWS_REGION'] || ENV['AMAZON_REGION'] || ENV['AWS_DEFAULT_REGION'] || 'ap-northeast-1'
# Enable regions as you like
# regions *%w(ap-northeast-1 ap-southeast-1 ap-southeast-2 eu-west-1 sa-east-1 us-east-1 us-west-1 us-west-2)

# You can use methods of AWS::EC2::Instance.
# See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/Instance.html
host_line <<END
Host <%= tag('Name') %>
  user admin
  HostName <%= public_dns_name == "" ? private_ip_address : public_dns_name %>
  identityfile ~/.ssh/id_rsa # 自分の利用しているpemを設定してください
  ForwardAgent yes
END
6. ec2ssh 업데이트 실행
.ssh/config 파일에는 인스턴스 이름의 host 이름이 있어야 합니다.
$ ec2ssh update
### EC2SSH BEGIN ###
# Generated by ec2ssh http://github.com/mirakui/ec2ssh
# DO NOT edit this block!
# Updated xxx
# section: default
Host test-ec2-ssh01
  user admin
  HostName ec2-xxx.xxx.xxx.xxx.amazonaws.com
  identityfile ~/.ssh/id_rsa
  ForwardAgent yes
Host test-ec2-ssh02
  user admin
  HostName ec2-xxx.xxx.xxx.xxx.amazonaws.com
  identityfile ~/.ssh/id_rsa
  ForwardAgent yes
・
・
### EC2SSH END ###

Updated /Users/XXXXX/.ssh/config
7. Host 이름 확인하고 메일 보내주세요.
할 수 있으면 끝!

총결산


ec2ssh를 이용하여 서버를 추가하여 ssh시간을 감소시켰습니다.
비록 매우 작지만, 나는 사람이 하지 않아도 되는 일은 가능한 한 이런 편리한 도구를 사용하여 낭비를 줄일 수 있다고 생각한다.

좋은 웹페이지 즐겨찾기