<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: chornos13</title>
    <description>The latest articles on DEV Community by chornos13 (@chornos13).</description>
    <link>https://dev.to/chornos13</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F340802%2F5b8f73b6-d2c2-4343-a5ec-6fa43b5ea5a0.png</url>
      <title>DEV Community: chornos13</title>
      <link>https://dev.to/chornos13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chornos13"/>
    <language>en</language>
    <item>
      <title>Gitlab-CI Config to deploy to your server via SSH</title>
      <dc:creator>chornos13</dc:creator>
      <pubDate>Thu, 16 Apr 2020 15:45:15 +0000</pubDate>
      <link>https://dev.to/chornos13/gitlab-ci-config-to-deploy-to-your-server-via-ssh-3ca2</link>
      <guid>https://dev.to/chornos13/gitlab-ci-config-to-deploy-to-your-server-via-ssh-3ca2</guid>
      <description>&lt;p&gt;&lt;strong&gt;STEP 1: Login SSH without password&lt;/strong&gt;&lt;br&gt;
ssh-keygen&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
Enter file in which to save the key (/home/user/.ssh/id_rsa): (input for custom filename)&lt;br&gt;
Enter passphrase (empty for no passphrase): (skip if you want)&lt;/p&gt;

&lt;p&gt;ssh-copy-id -i ~/.ssh/id_rsa.pub UserName@RemoteServer&lt;/p&gt;

&lt;p&gt;ref: &lt;a href="https://www.shellhacks.com/ssh-login-without-password/"&gt;https://www.shellhacks.com/ssh-login-without-password/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP 2: Pull Git without password on Server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Login to your server:&lt;br&gt;
ssh root@ip&lt;/p&gt;

&lt;p&gt;ssh-keygen -t ed25519 -C "&lt;a href="mailto:email@example.com"&gt;email@example.com&lt;/a&gt;"&lt;/p&gt;

&lt;p&gt;copy content from generated-file ssh to DEPLOY KEYS REPOSITORY GITLAB &lt;/p&gt;

&lt;p&gt;Testing that everything is set up correctly : &lt;br&gt;
ssh -T &lt;a href="mailto:git@gitlab.com"&gt;git@gitlab.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ref: &lt;a href="https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair"&gt;https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;git remote add bySSH &lt;a href="mailto:git@gitlab.com"&gt;git@gitlab.com&lt;/a&gt;:username/project.git&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP 3: Configure .gitlab-ci.yml&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;before_script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;apt-get update -qq&lt;/li&gt;
&lt;li&gt;apt-get install -qq git
# Setup SSH deploy keys&lt;/li&gt;
&lt;li&gt;'which ssh-agent || ( apt-get install -qq openssh-client )'&lt;/li&gt;
&lt;li&gt;eval $(ssh-agent -s)&lt;/li&gt;
&lt;li&gt;ssh-add &amp;lt;(echo "$SSH_PRIVATE_KEY")&lt;/li&gt;
&lt;li&gt;mkdir -p ~/.ssh&lt;/li&gt;
&lt;li&gt;'[[ -f /.dockerenv ]] &amp;amp;&amp;amp; echo -e "Host *\n\tStrictHostKeyChecking no\n\n" &amp;gt; ~/.ssh/config'&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;deploy_staging:&lt;br&gt;
  type: deploy&lt;br&gt;
  environment:&lt;br&gt;
    name: staging&lt;br&gt;
  script:&lt;br&gt;
    - ssh root@ip "cd /var/www/project-folder &amp;amp;&amp;amp; git checkout dev &amp;amp;&amp;amp; git pull bySSH dev &amp;amp;&amp;amp; npm install &amp;amp;&amp;amp; pm2 reload idpm2 &amp;amp;&amp;amp; exit"&lt;/p&gt;

&lt;p&gt;only:&lt;br&gt;
    - dev&lt;/p&gt;

&lt;p&gt;ref: &lt;a href="https://medium.com/@hfally/a-gitlab-ci-config-to-deploy-to-your-server-via-ssh-43bf3cf93775"&gt;https://medium.com/@hfally/a-gitlab-ci-config-to-deploy-to-your-server-via-ssh-43bf3cf93775&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gitlab</category>
      <category>ssh</category>
      <category>cd</category>
    </item>
  </channel>
</rss>
