what did I do before Link to heading

this is what I did before. and with the capacity of vm being relative small (hexo is memory consuming!!!), have to recreate my vm.

about aws Link to heading

I used aws as jenkins host. aws seems quicky to me because sometimes I got no permission sign in again to vm, even though I got the private key.

I searched a little and found possible reasons including changing permission on .ssh folders, not setting up correct permission to pem key, etc.

but since I am a light user on aws, I decide to going to force way!

permission denied (publickey) Link to heading

above is the error I met most, every time I met this, I was so frustrated, because I know it would be long time to debug and reason of this issue is not guaranteed to be found.

luckily, I found this. this may not be an elegant way, but solve my issue.

steps Link to heading

  1. first using private key into your aws ec2 instance, change current user to root.
  2. grant a password using passwd root
  3. back up /etc/ssh/sshd_config to /etc/ssh/sshd_config.bak using cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
  4. edit sshd_config file
  • PermitRootLogin to yes and comment out original line.
  • PasswordAuthentication to yes and comment out original line.
  1. save and run sshd -t. if no output, then there is no error.
  2. restart sshd using service sshd restart

by doing the above, every time I can guarantee login to root using password.

how to do auto deploy then. Link to heading

previously, I wrote bash script within jenkins directly. but since the user is jenkins and it lacks permission and environment to execute things, it is hard to keep doing so.

although it is worth mentioning by setting correct user to correct group, this issue can be solved, but I decide not to do this way.

I used brute force way, exporting essential PATH variables and execute things using user root.

for scripts, you can refer to this script.

Now I can finally focus on writting blog again.