ssh remote login

ssh Secure Shell protocol, Secure Shell, security protocol based on application layer and transport layer

ssh安装: sudo apt-get install openssh-server
Check if ssh is started: ps -e |grep ssh
ifconfig view ip address
Use ping check when ssh cannot connect, such as ping www.baidu.com

ssh_config: Configuration file for the client
sshd_config: configuration file for the server

ssh login: 

Method 1: ssh username@hostname (or ip address)
Method 2:
Change to home directory cd ~/.ssh/
New file touch ipconfig
vim ioconfig
enter
host "co1"
    HostName 192.168.0.108
    User root
    Port 22
host "co2"  

    HostName 192.168.0.108
    User root
    Port 22
save after exit
Type ssh co1 and ssh co2 in the terminal to achieve multiple remote terminal login
If you need to modify the port, you can modify the Port in /etc/ssh/sshd_config

The principle of key form login is to use a key generator to create a pair of keys—a public key and a private key. Add the public key to an account on the server, and then use the private key on the client to complete authentication and log in. This way, without the private key, no one can remotely log into the system by brute-forcing your password via SSH. In addition, if the public key is copied to another account or even the host, the private key can also be used to log in.

Key generation:
ssh-keygen , follow the prompts to enter the password file name key, and password (at least 5 digits), then key and key.pub will be generated in the current directory
.pub is the public key

Install the public key on the server:
cd ~/.ssh/
touch authorized_keys

cat key.pub >> authorized_keys
chmod 600 authorized_keys

chmod 700 ~/.ssh
Change setting
vim /etc/ssh/sshd_config

RSAAuthentication yes
PubkeyAuthentication yes
PermitRootLogin yes
PasswordAuthentication no

Restart ssh: service sshd restart

About scp command: https://www.vpser.net/manage/scp.html

Use on git

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325667401&siteId=291194637