Guest User

Untitled

a guest
Dec 5th, 2017
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. ## Prerequisites
  2.  
  3. * A working Debian/Ubuntu Linux instance
  4.  
  5. # Preparing the deployment server
  6.  
  7. After creating a VPS drop/node, login as `root` and update a newly installed system:
  8.  
  9. ```bash
  10. $ ssh root@12.34.56.78
  11. # Pasword: ...
  12. # > Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-101-generic x86_64).
  13. # > ...
  14. $ apt-get update
  15. $ apt-get upgrade
  16. $ apt-get dist-upgrade
  17. $ reboot
  18. ```
  19.  
  20. Wait a minute while system is rebooting, then login again.
  21.  
  22. ## Creating a deployer user
  23.  
  24. First of all, you’d like to add the `admin` group if it not exists:
  25.  
  26. ```bash
  27. $ addgroup admin
  28. ```
  29.  
  30. You can check `admin` group privileges using `visudo`:
  31.  
  32. ```bash
  33. $ visudo
  34. ```
  35.  
  36. There should be something like:
  37.  
  38. ```
  39. # Members of the admin group may gain root privileges
  40. %admin ALL=(ALL) ALL
  41. ```
  42.  
  43. Now you can create the `deployer` user:
  44.  
  45. ```bash
  46. $ adduser deployer
  47. ```
  48.  
  49. And add him to the `admin` group:
  50.  
  51. ```bash
  52. $ adduser deployer admin
  53. ```
  54.  
  55. The `deployer` user is successfully created, you can logout `root`:
  56.  
  57. ```bash
  58. $ exit
  59. ```
  60.  
  61. ## Connecting through the SSH without a password
  62.  
  63. The next step is optional, but it really helps you to save quite some time. I’m talking about SSH auto-logins, these will prevent the server from asking you for a password every time you’d like to connect.
  64.  
  65. On your local machine `cd` into the `~/.ssh` directory and generate an RSA key-pair:
  66.  
  67. ```bash
  68. $ cd ~/.ssh
  69. $ ssh-keygen -t rsa -C "yourname@yourcompany.com"
  70. # Generating public/private rsa key pair...
  71. ```
  72.  
  73. To keep things secure, you may want to have a separate key-pair for each server, to make it possible you need to have an ssh configuration file. If you haven‘t created it before, you can do it right now:
  74.  
  75. ```bash
  76. $ touch config
  77. ```
  78.  
  79. Add a new host/rsa entry to your config file:
  80.  
  81. ```bash
  82. $ vi config
  83. $ cat config
  84. # ...
  85. # Host yourhost
  86. # HostName 12.34.56.78
  87. # IdentityFile ~/.ssh/yourfile_rsa
  88. # ...
  89. ```
  90.  
  91. Now let’s see the contents of the public key, it should looks like the following:
  92.  
  93. ```bash
  94. $ cat yourfile_rsa.pub
  95. # ssh-rsa AAAAb4kzaC1 (text omitted) 86n3iEEQ78cPVazr yourname@yourcompany.com
  96. ```
  97.  
  98. Now what you have to do is to copy the contents of the created file to your clipboard, we’ll have to write it to a file on our remote server. Start by logging on to the server as `deployer`, proceed to the user’s `.ssh` directory and paste your public key into a file called `authorized_keys` (create it if it doesn’t exist). Save the file and close it, check that the contents have been written to the file and finally disconnect from the server:
  99.  
  100. ```bash
  101. $ ssh deployer@yourhost.com
  102. # Password: ...
  103. $ cd ~/.ssh
  104. $ vi authorized_keys
  105. $ cat authorized_keys
  106. # ssh-rsa AAAAb4kzaC1 (text omitted) 86n3iEEQ78cPVazr yourname@yourcompany.com
  107. $ exit
  108. ```
  109.  
  110. If you’ve done everything right, you should now be able to log on to the remote server from your computer without having to input a password:
  111.  
  112. ```bash
  113. $ ssh deployer@yourhost
  114. # > Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-101-generic x86_64).
  115. # > ...
  116. ```
Add Comment
Please, Sign In to add comment