When you create an instance on EC2, you get key pair file and you can log in to it with this file like this.
$ ssh -i /hoge/hoge.pem ec2-user@INSTANCE_NAMEIn this situation, you may get error message related to authentication when wordmove command because wordmove can't specify key pair file.
In order to resolve this issue, we can use public key authentication and setting of config of .ssh as below.
1. Generate original key
You generate public and secrete key on your local.$ ssh-keygen -t rsaThen you can find key files on ~/.ssh/.
2. Deploy public key on an instance
2-1. Transfer generated key above to the directory of ec2-user
$ scp -i hoge.pem ec2-user@INSTANCE_NAME:/home/ec2-userIf you want to user another user, you need to generate a user in advance and must transfer to a directory of this user.
2-2. Log in to EC2 server and confirm transfer
Log in to EC2 with key pair file.$ ssh -i /hoge/hoge.pem ~/.ssh/id_rsa.pub ec2-user@INSTANCE_NAME:/ec2-user/
Check transferred file.
$ cd /home/ec2-user $ ls
2-3. Deploy id_rsa.pub
Make a directory named ".ssh" then transfer id_rsa.pub with name of authorized_keys.$ mkdir /home/ec2-user/.ssh $ sudo mv ./id_rsa.pub ./.ssh/authorized_keys
2-4. Change permission of transferred file and made directory
$ sudo chmod 600 /home/ec2-user/.ssh/authorized_keys $ sudo chmod 700 /home/ec2-user/.ssh
3. Connect via ssh
Run this command and it's successful if you can login.$ ssh ec2-user@INSTANCE_NAME
4. Add config file on .ssh
With setting till here, you can use wordmove command but it's more useful to add config file when log in with command of ssh. On your local PC, you can write config file like this.$ vi ~/.ssh/config Host hoge user ec2-user HostName PUBLIC_DNS_OF_INSTANCE Port 22 IdentityFile id_rsa
If you can log in to the instance with this command, this setting is successful.
$ ssh hoge
0 Comments:
Post a Comment