Usage of ssh/scp/sshfs

Table of Contents

1 Install openssh-server

In case of Ubuntu 16.04 / Debian 8 is as below.

$ sudo apt install -y openssh-server$ sudo systemctl enable ssh # enabled by default$ sudo systemctl start ssh # started by default

In case of Fedora 24 is as below.

$ sudo dnf install -y openssh-server$ sudo systemctl enable sshd$ sudo systemctl start sshd

In case of CentOS 7 is as below.

$ sudo yum install -y openssh-server$ sudo systemctl enable sshd$ sudo systemctl start sshd

2 Public key authentication for no passphrase

Public key authentication can skip passphrase. In case of Windows, this article uses teraterm as ssh client.

2.1 Client (Linux/Unix)

Create public key and private key. Make passhrase be empty for no passhurase.

$ ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/hiroom2/.ssh/id_rsa):Created directory ‘/home/hiroom2/.ssh’.Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /home/hiroom2/.ssh/id_rsa.Your public key has been saved in /home/hiroom2/.ssh/ key fingerprint is:

The private key is created at ${HOME}/.ssh/id_rsa and public key at ${HOME}/.ssh/

$ ls -l ~/.sshtotal 8-rw——- 1 hiroom2 hiroom2 1675 6月 29 17:26 id_rsa-rw-r–r– 1 hiroom2 hiroom2 399 6月 29 17:26

Copy to server. This needs passphrase yet.

$ scp .ssh/ <server>:${HOME}/

2.2 Client (Windows)

Create public key and private key with teraterm.

Select SSH KeyGenerator.


Generate with RSA and 2048 bit by default.


Make passhrase be empty for no passhurase, and select Save public key / Save private key.


Copy to server.

The teraterm needs setting for public key authentication.

Select SSH Authentication.


Input username and set created id_rsa as Private key file. Select OK.


Select Save setup and overwrite to below file.

C:Program Files (x86)teratermTERATERM.ini


Input server IP address or hostname at New connections. Select OK.


id_rsa is used for SSH authentication by default. Select OK and connect to server.


2.3 Server

Add created by client to ${HOME}/.ssh/authorized_keys.

$ cat >> ${HOME}/.ssh/authorized_keys

ssh/scp/sshfs commands does not need pass phrase.

3 Disable checking known_hosts for some host

ssh detects server spoofing with ${HOME}/.ssh/known_hosts. This is good for security but inconvenience for virtual machine.

This article will disable checking known_hosts for network and * domain.

$ cat .ssh/configHost 192.168.11.* StrictHostKeyChecking no UserKnownHostsFile=/dev/nullHost * StrictHostKeyChecking no UserKnownHostsFile=/dev/null

4 File transfer with scp command

The scp command transfer file between client and server. It is included in openss-client/openssh-clients package.

$ sudo apt install -y openssh-client # Ubuntu 16.04 / Debian 8$ sudo dnf install -y openssh-clients # Fedora 24$ sudo yum install -y openssh-clients # CentOS 7

In case of file is as below.

$ scp <path-to-file> <server>:<path-to>$ scp <server>:<path-to-file> <path-to>

In case of directory is as below.

$ scp -r <path-to-dir> <server>:<path-to>$ scp -r <server>:<path-to-dir> <path-to>

4.1 WinSCP

 WinSCP provides scp command on Windows.

Run WinSCP and input server setting. For public authentication, WinSCP allow only keys created by putty and need exchange keys created by teraterm.


Connect to server.


5 Mount server directory with sshfs

Install sshfs with apt、yum、dnf and homebrew.

$ sudo apt install -y sshfs # Ubuntu 16.04 / Debian 8$ sudo yum install -y sshfs # CentOS 7 with EPEL repository$ sudo dnf install -y sshfs # Fedora 24$ brew install sshfs # OSX

sshfs only do mount.

$ sshfs mnt$ ls mnt/Desktop Downloads Pictures Templates bin mntDocuments Music Public Videos examples.desktop src

fusermount or umount is needed for unmount.

$ fusermount -u mnt # Run “umount mnt” on OSX

There is no sshfs client for Windows 10. win-sshfs will work on Windows 10.

Android | Linux | SDL - Narrow Escape