Skip to content

Instantly share code, notes, and snippets.

@sandys
Last active March 10, 2026 17:13
Show Gist options
  • Select an option

  • Save sandys/a5f0c4ac3b632f08f0a0ae185ca99fc6 to your computer and use it in GitHub Desktop.

Select an option

Save sandys/a5f0c4ac3b632f08f0a0ae185ca99fc6 to your computer and use it in GitHub Desktop.
running anything in the background (very simply!!)

how to use github clone (with ssh keys) on server, without copying ssh keys to server

  • Test github connection on your laptop using ssh -T git@github.com you will get response
Warning: Permanently added the ECDSA host key for IP address '140.82.116.4' to the list of known hosts.
Hi sandys! You've successfully authenticated, but GitHub does not provide shell access.

this is good

  • on your laptop, run ssh-agent using eval "$(ssh-agent -s)"

  • on your laptop, run ssh-add (if you have many keys, you will have to choose the right one or add all of them). ssh-add /home/sss/.ssh/id_ed25519

  • then ssh to server using "-A" flag. ssh -A sss@34.82.189.191

  • once you are on the server, run tmux (see above). like tmux new-session -A -s sss1

  • now try again, ssh -T git@github.com

  1. you should see the same successful message as above inside tmux
Hi sandys! You've successfully authenticated, but GitHub does not provide shell access.

if you have failed, you will see the following message

git@github.com: Permission denied (publickey).

How to Run a Process in the Background with TMUX

There are times when you need to shutdown your laptop, and you want a server process (like a chromium compile) to run in the background. TMUX manages this very well. you dont need to figure some weird "&" syntax or anything

For this example, let's suppose you're running a long running task like running rspecs on your project and it is 5pm, and you need to go home.

Run Your Process

1. First launch TMUX

$ tmux new-session -A -s  sss1

Start a new session or attach to an existing session named sss1

2. Run your long running process

$ something long long long 

3. Detach from TMUX

Simply press [CTRL]+[b] (together and then leave them), then [d]. This will detach your session from TMUX.

NOTE: you can do this while your long process is running. Dont be afraid!

4. Log off

Now you can simply log off

Show all sessions on the computer

$ tmux ls

this will show you all running sessions

root@Ubuntu-2404-noble-amd64-base ~ # tmux ls
sss1: 1 windows (created Sat Aug 31 21:31:41 2024)
sss2: 1 windows (created Sat Aug 31 21:31:44 2024)

Return to your session

When you return back to your desktop, open a terminal and simply run:

$ tmux new-session -A -s  sss1

This will attach to your detached TMUX session. you will see all the screen output and everything. its just like as if ur terminal was running and you just opened it now. no mess of background processes.

Anytime u want to detach again, simply press [CTRL]+[b], then [d]. to exit, just type exit in ur tmux session. that session ends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment