DEV Community

Kannan
Kannan

Posted on

Deploy codes to remote server over SSH method

  • Create a Git Repository name "deploycode" add README.md file mention description as deploycodetoremoteserver.

  • Clone the Git repo to local machine.

  • Create Git branch as "dev" & "test"

  • Create index.html file for both branches

kannan@kannan-PC:~/deploycode$ ls
index.html  README.md
kannan@kannan-PC:~/deploycode$ cat index.html 
<h1>Testcode</h1>
<h1>testcode version-1</h1>
<h1>testcode version-2</h1>

kannan@kannan-PC:~/deploycode$ git branch 
  dev
  main
* test
kannan@kannan-PC:~/deploycode$ git checkout dev
Switched to branch 'dev'
kannan@kannan-PC:~/deploycode$ git branch 
* dev
  main
  test
kannan@kannan-PC:~/deploycode$ ls
index.html  README.md
kannan@kannan-PC:~/deploycode$ cat index.html 
<h1>Devcode </h1>
<h1>dev code version-1</h1>
<h1>dev code version-2</h1>

Enter fullscreen mode Exit fullscreen mode
  • Git add . and commit, Push to the Git repo.

Remote server setup

  • Create a remote server

  • Do the "apt update" and and "install apache2" on the both server

  • Do the the "systemctl start, enable, status of the apache service"

Jenkins setup

  • Go to Jenkins dashboard > Manage Jenkins > Plugins > "publish over SSH"

  • Manage Jenkins > System > SSH Servers (Add the SSH server details for dev and test)

Image description

Image description

  • Click on advance "Use password authentication" enter the password for the remote server.

Image description

  • Test run the configuration to check the remote server connectivity.

Jenkins Project for devserver.

  • Go to Jenkins dashboard > Add items > Freestyle project> ok

  • Select the Github project and paste the Git repo "URL".
    Image description

  • Copy the Git repo http url and mention the branch as "dev"

Image description

  • Select the "Poll SCM" and set the schedule period.
    Image description

  • Select send files or execute commands over SSH.
    Image description

  • Select Editable e mail Notification, add the email on "Project recipient list"

Image description

  • Once done it will automatically Build Now and provides the output on Console output.

Image description

Image description

Jenkins Project for testserver.

  • Follow the same configuration procedure as the above "General, source code management, Build trigger, Post buils action".
  • Only need to modify the Build steps to run the "testserver"

Image description

  • Once done it will automatically Build Now and provides the output on Console output.

Image description

Image description

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more