Ubuntu opens SSH service for remote login and file transfer

Secure Shell (SSH) is an encrypted network transmission protocol. The most common use of SSH is to log in to the system remotely. People usually use SSH to transmit command line interfaces and execute commands remotely. The most frequently used occasions are Unix-like systems, but Windows operating systems can also use SSH to a limited extent. In 2015, Microsoft announced that it would provide native SSH protocol support in future operating systems. Windows 10 version 1809 has provided OpenSSH tools that can be manually installed.

Test platform: ubuntu14.04 (root user)-client ubuntu16.04 (fh ordinary user)-server

That is, ubuntu log in to ubuntu, and I will have the opportunity to share with you the operation of Windows logging in to Ubuntu.

  1. SSH is divided into Client and Server

Ubuntu comes with SSH Client by default, and the port number is 22. If not, you can install it via sudo apt-get install openssh-client. If it is used as a server, SSH Server needs to be installed.

  1. Install SSH Server and start

①Check if SSH Server is installed

dpkg -l|grep ssh

In the picture, only SSH Client is installed

②Install SSH Server

sudo apt-get install openssh-server

③Check whether the installation is successful &&Check whether the startup is successful

1> dpkg -l|grep ssh

The result in the figure shows that the SSH Server is installed successfully

2> ps -e|grep ssh

Sshd indicates that SSH Server has been started successfully

If it is not started, it can be started in the following two ways:

sudo /etc/init.d/ssh start

sudo service ssh start

  1. SSH Server related configuration

The SSH Server configuration file is in /etc/ssh/sshd_config,

① Here you can set the SSH Server port, the default is 22, the figure has been modified to 666

②Allow root users to log in with any authentication method

Block PermitRootLogin without-password, increase PermitRootLogin yes

③Restart SSH Server

sudo /etc/init.d/ssh stop

sudo /etc/init.d/ssh start

  1. Ubuntu root login SSH

①Modify SSH Client port

The configuration file is in /etc/ssh/ssh_config

Client and Server need to be pinged

②Terminal login command:

ssh [email protected]

username is the user name of 192.168.15.128, 192.168.15.128 is the IP address of the SSH Server

You need to enter the root password of username when logging in

The login is successful as shown in the figure: Use ls in the SSH Client to view the current file list

Comparison of the results of using the ls command on the SSH Server side:

③Logout command

exit

  1. New file test

①SSH Client uses the touch command to create a new dh.txt file

② SSH Server side renderings

  1. SSH Client uses scp command to get SSH Server file

①Create a new dh6.txt on the SSH Server, the content of the file is hello world!

② SSH Client to get files

scp username@servername:/path/file /local_dir (local directory)

Recommended Posts

Ubuntu opens SSH service for remote login and file transfer
Simple and clean install remote login for ubuntu18
Method steps for installing and configuring SSH service under Ubuntu 18.04
Ubuntu ssh-keygen remote login
File transfer method between Windows and Ubuntu on VMware
Open SSH service under Ubuntu
ubuntu 16.10 supports ssh remote access
Open SSH service under Ubuntu
Windows Ubuntu subsystem ssh and ftp
Ubuntu19.10 open ssh service (detailed process)