Remote git with ssh

Working on a different architecture from my Laptop means that I am invariably working on a remote machine. My current development can be done on an Ampere AltraMax machine, which means I have 80 processors available; quite a nice benefit when doing a Linux Kernel compile that can use all of the processors available.

Because the machine is a shared resource out of out lab, I want to make sure I can recreate my work there on another machine; this one could be reclaimed or powered down due to lab priorities. Thus, all my remote work is done in git, and I use the ssh protocol to pull changes from my work server to my laptop fairly regularly…whenever I feel I have valuable work that could be potentially lost.

I will assume that you can figure out how to create a git repo on work machine (write a comment if you really feel that would be necessary to expand) and will just show how to pull it onto my laptop.

Here are the steps:

  • create a local git repo.
  • add your remote server ssh login as a git remote
  • git fetch from the remote server.

Here’s what it looks like:

mkdir myproj
cd myproj
git remote add eng16sys root@eng16sys:devel/myproj
git fetch eng16sys

That last command will generate output like this:

remote: Enumerating objects: 13, done.
remote: Counting objects: 100% (13/13), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 13 (delta 3), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (13/13), 3.07 KiB | 785.00 KiB/s, done.
 * [new branch]      main       -> eng16sys-r105/main

This is a two-way setup in that I can push code from my laptop to the server as well. However, since I don’t have ssh from the server back to my laptop, I cannot pull code to the server from my laptop from a command prompt on the server. This is security constraint; I don’t want to allow people that have access to my server (a shared resource) to also have access to my personal laptop.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.