当前位置:网站首页>Introduction of SSH
Introduction of SSH
2022-08-06 05:14:00 【Dynamic shuang, refactoring crematorium】
Installation and basic usage
The installation client can be installed by the following command
# ubuntu debianapt-get install openssh-client#centos fedoradnf install openssh-clientsGeneral connection usage is ssh [email protected]
-p port : specify the ssh port, the default is 22-N : Indicates that the SSH established by port forwarding is only used for port forwarding, and cannot execute remote commandsConnection Process
For the first connection, the remote server public key hash value will be stored on the client side
Specifically stored in the ~/.ssh/known_hosts file
If the server public key hash changes, it will be inconsistent with the storage.In this case, you can delete the public key corresponding to the hostname through
ssh-keygen -R hostname, of course, you can also delete it manually in the file
Configuration
Configuration file location
~/.ssh/id_rsa: RSA private key for SSH protocol version 2.~/.ssh/id_rsa.pub: RSA public key for SSH protocol version 2.~/.ssh/config: User's personal ssh configuration file/etc/ssh/ssh_config: global ssh configuration file~/.ssh/identity: RSA private key for SSH protocol version 1.~/.ssh/identity.pub: RSA public key for SSH protocol version 1.~/.ssh/known_hosts: Contains the public key fingerprint of the SSH server.~/.ssh/id_ecdsa: user's ECDSA private key~/.ssh/id_ecdsa.pub: user's ECDSA public key
SSH configuration
Thesyntax is a configuration command followed by a value.It can be followed by a space or equal to
# Configure username and password# For example, for host remoter.comHost remoteSSHHostName remoter.comUser rootPort 2222# Then ssh remote SSH is equivalent to ssh -p 2222 [email protected]Key login
The ssh key login process is as follows
- The client generates public and private keys through ssh-keygen
- Put the client public key into the
~/.ssh/authorized_keys of the corresponding user on the remote server - The client initiates an SSH login request to the server
- After the server receives the request, it will send random data to the user, asking for proof of identity
- The client receives the data from the server, signs the data with the private key, and sends it to the server
- After the server receives the encrypted signature, it decrypts it with the public key, and if it is consistent, the user is allowed to log in
ssh-keygen
# Generatessh-keygen# removessh-keygen -R example.comPort Forwarding
Native port forwarding
Forward the access request to the designated port X of local machine A to the Y port of host B
ssh -L [access address] local port X: remote host B: remote host B portRemote Port Forwarding
After establishing a local-to-remote SSH tunnel, enable the remote server to access the local machine
ssh -R remote port: remote server IP: remote server portFor example, if host A runs a virtual machine, then host B under the same local area network can execute the following command on host A to achieve port 1234 through host B
ssh -R host A port: virtual machine a IP: virtual machine a port host B [email protected] B IPDynamic forwarding
The local machine has established an encrypted connection with the remote SSH server, and the access to a certain port of the local machine is forwarded through this encrypted connection
ssh -D localhost A port X remote SSH serverFor example, if the local port 2121 is connected to the remote SSH server remoteSSHHost, the dynamic forwarding command is as follows
ssh -D 2121 remoteSSHHost# User access request.Specify the local port 2121 of the sock5 protocol to access www.example.comcurl -x sock5://localhost:2121 http://www.example.comServer
The ssh server can be installed with the following command
# Debian$ sudo aptitude install openssh-server#Red Hat$ sudo yum install openssh-serverThe configuration file of sshd is in the /etc/ssh directory, the main configuration file is sshd_config, and there are also some keys generated during installation.
/etc/ssh/sshd_config: Configuration file/etc/ssh/ssh_host_ecdsa_key: ECDSA private key./etc/ssh/ssh_host_ecdsa_key.pub: ECDSA public key./etc/ssh/ssh_host_key: RSA private key for SSH 1 protocol version./etc/ssh/ssh_host_key.pub: RSA public key for SSH 1 protocol version./etc/ssh/ssh_host_rsa_key: RSA private key for SSH 2 protocol version./etc/ssh/ssh_host_rsa_key.pub: RSA public key for SSH 2 protocol version./etc/pam.d/sshd: PAM configuration file.
sshd_config can configure many items, only some of them are described below
- PasswordAuthentication whether to allow password login, the default is yes
- ClientAliveCountMax specifies the number of times the server attempts to connect when the client loses response after the connection is established (
ClientAliveCountMax 8) - Port represents the sshd listening port, the default is 22
Ref
- https://wangdoc.com/ssh/port-forwarding.html
- https://zhuanlan.zhihu.com/p/148825449
边栏推荐
- What are the application scenarios of LoRa technology?
- "Module + antenna" full stack solution, to speed up the Internet of things terminal efficient deployment
- Practical debugging tips
- WindowsServer下配置Mysql主从同步---Mysql主从复制同步001
- el-table样式修改
- dedecms collection selection content model display complete
- 牛刀小试基本语法,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang基本语法和变量的使用EP02
- Niu Ke topic - the best time to buy and sell stocks (1), (2), (3), design LRU cache structure
- 路由-route
- Bee使用postgresql数据库插入记录后返回ID值
猜你喜欢

Introduction and use of Jhipster

数学建模学习(77):matlab相关性分析(皮尔逊,肯德尔,斯皮尔曼)

7. Building RESTful Services

fegin feign.FeignException: status 404 reading StudentService#getAll()

信息系统项目管理师必背核心考点(六十一)项目组合概念

代码格式规范--clang-format的安装及配置

2022 Practical Content Course on Building Modern Web Applications with Go

Backup and restore Etcd data in a Kubernetes cluster

从业务开发中学习和理解架构设计

网络空间测绘——MQTT服务篇
随机推荐
SkyEye在航电系统冗余设计中的应用前景
学习总结week3_5文件操作
LoRa技术有哪些应用场景?
如何保持注意力,高效学习
Detailed BGP (1)
Introduction and use of Jhipster
"Module + antenna" full stack solution, to speed up the Internet of things terminal efficient deployment
百度智能云数字人凭什么领跑中国AI数字人?
Oracle Recovery Tools 解决ORA-600 3020故障
extends继承
Simple sample code of google's lightweight DI framework guice
623. 在二叉树中增加一行
【D1 Dock Pro开发板】LED灯闪烁
Basis of database
el-table style modification
温度敏感/PH敏感/电场敏感/温度/pH双重敏感/磁场敏感型水凝胶的制备
2022年国外受欢迎的海外社交平台排行榜!
Flutter performance optimization TAB, switch back without rendering again
跨域请求处理之配置代理模式
瑞吉外卖项目实战Day03