Simple SSH Setup For Ubuntu and Linux Mint
Most Linux distributions come with the SSH client already installed. If you want to use SSH to log into a remote machine, you will have to install the server application on that machine and make sure it’s up and running.
SSH Server Setup:
Your router may not be running a local host name server. Most modern routers don’t. In that case, The SSH server machine should be set with a static IP address on the local network. You should do this first before installing the server software.
You will need to know the gateway address, netmask, available IP addresses for your local network and DNS server addresses.
To find your gateway address:
The gateway is the address of your router. It should be something like 192.168.0.1.
To find you current IP address and netmask:
(If ifconfig is not already installed run: sudo apt install net-tools)
Your current IP4 address is prefaced with ‘inet’ and the netmask is listed right after it. Ex. “inet 192.168.0.11 netmask 255.255.255.0 broadcast 192.168.0.255”
You will need to set addresses for Domain Name System servers so your system can find web sites. This is usually done automatically through DHCP but we will do it manually. You can get DNS from your ISP or use an open DNS. I prefer 22.214.171.124 and 126.96.36.199. To learn more: https://www.cloudflare.com/learning/dns/what-is-188.8.131.52/
Reboot and confirm the new static IP is working properly.
Install SSH server:
sudo apt install openssh-server
Once installed, the server should automatically start itself and the machine will be waiting for logins from other machines on the network through port 22. Be sure to allow traffic on port 22 through any firewalls.
You must type in “yes” and provide the password for the account you’re logging into on the remote machine.
SFTP works very much like FTP but uses a secure SSH connection.
To make login a little easier use this script or set the command as an alias:
# SSH login shorthand command: “sshin (last two digits of IP)”
ssh -X 192.168.0.”$1″
The -X option turns on X forwarding.
Use SSH Keys:
Keys make for grater security and automate login. There are many options and ways to work with SSH keys. This is a very simplified way to get started with SSH keys.
Generate keys on cleat machine:
Accept the default file name and path. For passphrase, just press enter.
Confirm key creation with:
Copy public key to server:
You may now login automatically. You might consider turning off password access to the server to make it more secure. Don’t copy you personal ssh key (id_rsa) to the server unless you intend to log into other machines on your local network from that machine. You should never put your private key on servers running on the public internet.
To take advantage of secure file sharing through SSH, you’ll need to have the SSHFS client installed on the client machines. Install it on the server if that machine will also be an ssh client
sudo apt install sshfs
Access files on remote machines:
sshfs (user@)host:(dir) mountpoint (options)
Ex. sshfs 192.168.0.20:Documents/ Shared-Documents/ -o reconnect
Add a command like this to your startup applications or put several in a script to setup secure file sharing automatically.
This time it’s for real… I am going to take a break from posting on YouTube for a while. You also may notice fewer posts on Facebook and EzeeTalk but I will be answering messages and e-mails, as usual. You may have heard about the terrible shooting tragedy in Va. Beach. That is just down the road from me and it was quite a shock to everyone in the area. It has reminded me that life is short and that it’s important to take care of yourself and be happy. We never know when this ride will end. Thanks as always to all of you for your support. Look for new videos coming in July.