Skip to content

SSH Setup

SSH is a secure protocol used as the primary means of connecting to Linux servers remotely. It provides a text-based interface by spawning a remote shell. After connecting, all commands you type in your local terminal are sent to the remote server and executed there.

To generate an SSH key

ssh-keygen

To transfer an SSH key to the remote computer

ssh-copy-id -i ~/.ssh/mykey user@host

Add key to ssh agent

GitHub Error
For error:
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

ssh-add ~/.ssh/mykey

Config file

Host *
     ServerAliveInterval 120

Host <nick name of the host>
     Hostname <host address>
     User <user name>
     IdentityFile ~/.ssh/
     ForwardX11 yes
     ForwardX11Trusted yes

Note: Always make sure to change .ssh directory permission to 600.

chmod -R 600 ~/.ssh/

Allow password login a GCP instance user

This is to enable password login to a non-sudo/root user on a Google cloud instance.

sudo vi /etc/ssh/sshd_config

Then, change the line: PasswordAuthentication no to PasswordAuthentication yes

sudo service ssh restart

SSHFS

In computing, SSHFS (SSH Filesystem) is a filesystem client to mount and interact with directories and files located on a remote server or workstation over a normal ssh connection. The client interacts with the remote file system via the SSH File Transfer Protocol (SFTP), a network protocol providing file access, file transfer, and file management functionality over any reliable data stream that was designed as an extension of the Secure Shell protocol (SSH) version 2.0.

To mount create a mount point (directory)

sshfs user@host:/folder/to/mount/ mount/point