Debug Remotely on Android using adb via SSH Tunnel

Start adb daemon on remote device

adb devices
$ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 
5200fe4259bcc000	device

do client to server port forwarding using ssh on port 5037


Tmux Cheat Sheet & Quick Reference

Start a new session

tmux new
tmux new-session

Start a new session with the name mysession

tmux new -s mysession

kill/delete session mysession

tmux kill-session -t mysession

kill/delete all sessions but the current

tmux kill-session -a

kill/delete all sessions but mysession

tmux kill-session -a -t mysession

Show all sessions

tmux ls
tmux list-sessions

Attach to a session with the name mysession

tmux a -t mysession
tmux at -t mysession
tmux attach -t mysession
tmux attach-session -t mysession

Rename session

Ctrl + b $

Detach from session

Ctrl + b d

Create window

Ctrl + b c

Rename current window

Ctrl + b ,

Close current window

Ctrl + b &

Previous window

Ctrl + b p

Next window

Ctrl + b n

Switch/select window by number

Ctrl + b 0 ... 9


Ctrl-b [
# Press q to quit scroll mode
Ctrl-b PgUp


Keep Alive SSH Sessions

To enable the keep alive system-wide (root access required), edit /etc/ssh/ssh_config;
to set the settings for just your user, edit ~/.ssh/config (create the file if it doesn’t exist). Insert the following:

Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2

You can also make your OpenSSH server keep alive all connections with clients by adding the following to /etc/ssh/sshd_config:

ClientAliveInterval 300
ClientAliveCountMax 2


Set Up SSH Keys on Ubuntu

Create the RSA Key Pair

ssh-keygen -t rsa -b 4096 -C ""

Copy the Public Key to Ubuntu Server

cat ~/.ssh/ | ssh username@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"

or Copying Public Key Manually

To display the content of your key, type this into your local computer:

cat ~/.ssh/

You will see the key’s content, which should look something like this:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCqql6MzstZYh1TmWWv11q5O3pISj2ZFl9HgH1JLknLLx44+tXfJ7mIrKNxOOwxIxvcBF8PXSYvobFYEZjGIVCEAjrUzLiIxbyCoxVyle7Q+bqgZ8SeeM8wzytsY+dVGcBxF6N4JS+zVk5eMcV385gG3Y6ON3EG112n6d+SMXY0OEBIcO6x+PnUSGHrSgpBgX7Ks1r7xqFa7heJLLt2wWwkARptX7udSq05paBhcpB0pHtA1Rfz3K2B+ZVIpSDfki9UVKzT8JUmwW6NNzSgxUfQHGwnW7kj4jp4AT0VZk3ADw497M2G/12N0PPB5CnhHf7ovgy6nL1ikrygTKRFmNZISvAcywB9GVqNAVE+ZHDSCuURNsAInVzgYo9xgJDW8wUw2o8U77+xiFxgI5QSZX3Iq7YLMgeksaO4rBJEa54k8m5wEiEE1nUhLuJ0X/vh2xPff6SQ1BL/zkOhvJCACK6Vb15mDOeCSq54Cr7kvS46itMosi/uS66+PujOO+xt/2FWYepz6ZlN70bRly57Q06J+ZJoc9FfBCbCyYH7U/ASsmY095ywPsBo1XQ9PqhnN1/YOorJ068foQDNVpm146mUpILVxmq41Cj55YKHEazXGsdBIbXWhcrRf4G2fJLRcGUr9q8/lERo9oxRm5JFX6TCmj6kmiFqv+Ow9gI0x8GvaQ== demo@test

make sure the ~/.ssh directory exists.This command will create the directory if necessary, or do nothing if it already exists:

mkdir -p ~/.ssh

Now, you can create or modify the authorized_keys file within this directory. You can add the contents of your file to the end of the authorized_keys file, creating it if necessary, using this command:

echo public_key_string >> ~/.ssh/authorized_keys

Finally, we’ll ensure that the ~/.ssh directory and authorized_keys file have the appropriate permissions set:

chmod -R go= ~/.ssh

or Copy using ssh-copy-id

ssh-copy-id demo@
ssh-copy-id demo@ -p 22000

Authenticate to Ubuntu Server Using SSH Keys

ssh username@remote_host

Disable Password Authentication on your Server

sudo nano /etc/ssh/sshd_config
PasswordAuthentication no
sudo systemctl restart ssh

Convert private key to putty 

puttygen keyname -o keyname.ppk

ssh “permissions are too open” error

Keys need to be only readable by you:

chmod 400 ~/.ssh/id_rsa

If Keys need to be read-writable by you:

chmod 600 ~/.ssh/id_rsa