• Guest
HabraHabr
  • Main
  • Users

  • Development
    • Programming
    • Information Security
    • Website development
    • JavaScript
    • Game development
    • Open source
    • Developed for Android
    • Machine learning
    • Abnormal programming
    • Java
    • Python
    • Development of mobile applications
    • Analysis and design of systems
    • .NET
    • Mathematics
    • Algorithms
    • C#
    • System Programming
    • C++
    • C
    • Go
    • PHP
    • Reverse engineering
    • Assembler
    • Development under Linux
    • Big Data
    • Rust
    • Cryptography
    • Entertaining problems
    • Testing of IT systems
    • Testing Web Services
    • HTML
    • Programming microcontrollers
    • API
    • High performance
    • Developed for iOS
    • CSS
    • Industrial Programming
    • Development under Windows
    • Image processing
    • Compilers
    • FPGA
    • Professional literature
    • OpenStreetMap
    • Google Chrome
    • Data Mining
    • PostgreSQL
    • Development of robotics
    • Visualization of data
    • Angular
    • ReactJS
    • Search technologies
    • Debugging
    • Test mobile applications
    • Browsers
    • Designing and refactoring
    • IT Standards
    • Solidity
    • Node.JS
    • Git
    • LaTeX
    • SQL
    • Haskell
    • Unreal Engine
    • Unity3D
    • Development for the Internet of things
    • Functional Programming
    • Amazon Web Services
    • Google Cloud Platform
    • Development under AR and VR
    • Assembly systems
    • Version control systems
    • Kotlin
    • R
    • CAD/CAM
    • Customer Optimization
    • Development of communication systems
    • Microsoft Azure
    • Perfect code
    • Atlassian
    • Visual Studio
    • NoSQL
    • Yii
    • Mono и Moonlight
    • Parallel Programming
    • Asterisk
    • Yandex API
    • WordPress
    • Sports programming
    • Lua
    • Microsoft SQL Server
    • Payment systems
    • TypeScript
    • Scala
    • Google API
    • Development of data transmission systems
    • XML
    • Regular expressions
    • Development under Tizen
    • Swift
    • MySQL
    • Geoinformation services
    • Global Positioning Systems
    • Qt
    • Dart
    • Django
    • Development for Office 365
    • Erlang/OTP
    • GPGPU
    • Eclipse
    • Maps API
    • Testing games
    • Browser Extensions
    • 1C-Bitrix
    • Development under e-commerce
    • Xamarin
    • Xcode
    • Development under Windows Phone
    • Semantics
    • CMS
    • VueJS
    • GitHub
    • Open data
    • Sphinx
    • Ruby on Rails
    • Ruby
    • Symfony
    • Drupal
    • Messaging Systems
    • CTF
    • SaaS / S+S
    • SharePoint
    • jQuery
    • Puppet
    • Firefox
    • Elm
    • MODX
    • Billing systems
    • Graphical shells
    • Kodobred
    • MongoDB
    • SCADA
    • Hadoop
    • Gradle
    • Clojure
    • F#
    • CoffeeScript
    • Matlab
    • Phalcon
    • Development under Sailfish OS
    • Magento
    • Elixir/Phoenix
    • Microsoft Edge
    • Layout of letters
    • Development for OS X
    • Forth
    • Smalltalk
    • Julia
    • Laravel
    • WebGL
    • Meteor.JS
    • Firebird/Interbase
    • SQLite
    • D
    • Mesh-networks
    • I2P
    • Derby.js
    • Emacs
    • Development under Bada
    • Mercurial
    • UML Design
    • Objective C
    • Fortran
    • Cocoa
    • Cobol
    • Apache Flex
    • Action Script
    • Joomla
    • IIS
    • Twitter API
    • Vkontakte API
    • Facebook API
    • Microsoft Access
    • PDF
    • Prolog
    • GTK+
    • LabVIEW
    • Brainfuck
    • Cubrid
    • Canvas
    • Doctrine ORM
    • Google App Engine
    • Twisted
    • XSLT
    • TDD
    • Small Basic
    • Kohana
    • Development for Java ME
    • LiveStreet
    • MooTools
    • Adobe Flash
    • GreaseMonkey
    • INFOLUST
    • Groovy & Grails
    • Lisp
    • Delphi
    • Zend Framework
    • ExtJS / Sencha Library
    • Internet Explorer
    • CodeIgniter
    • Silverlight
    • Google Web Toolkit
    • CakePHP
    • Safari
    • Opera
    • Microformats
    • Ajax
    • VIM
  • Administration
    • System administration
    • IT Infrastructure
    • *nix
    • Network technologies
    • DevOps
    • Server Administration
    • Cloud computing
    • Configuring Linux
    • Wireless technologies
    • Virtualization
    • Hosting
    • Data storage
    • Decentralized networks
    • Database Administration
    • Data Warehousing
    • Communication standards
    • PowerShell
    • Backup
    • Cisco
    • Nginx
    • Antivirus protection
    • DNS
    • Server Optimization
    • Data recovery
    • Apache
    • Spam and antispam
    • Data Compression
    • SAN
    • IPv6
    • Fidonet
    • IPTV
    • Shells
    • Administering domain names
  • Design
    • Interfaces
    • Web design
    • Working with sound
    • Usability
    • Graphic design
    • Design Games
    • Mobile App Design
    • Working with 3D-graphics
    • Typography
    • Working with video
    • Work with vector graphics
    • Accessibility
    • Prototyping
    • CGI (graphics)
    • Computer Animation
    • Working with icons
  • Control
    • Careers in the IT industry
    • Project management
    • Development Management
    • Personnel Management
    • Product Management
    • Start-up development
    • Managing the community
    • Service Desk
    • GTD
    • IT Terminology
    • Agile
    • Business Models
    • Legislation and IT-business
    • Sales management
    • CRM-systems
    • Product localization
    • ECM / EDS
    • Freelance
    • Venture investments
    • ERP-systems
    • Help Desk Software
    • Media management
    • Patenting
    • E-commerce management
    • Creative Commons
  • Marketing
    • Conferences
    • Promotion of games
    • Internet Marketing
    • Search Engine Optimization
    • Web Analytics
    • Monetize Web services
    • Content marketing
    • Monetization of IT systems
    • Monetize mobile apps
    • Mobile App Analytics
    • Growth Hacking
    • Branding
    • Monetize Games
    • Display ads
    • Contextual advertising
    • Increase Conversion Rate
  • Sundry
    • Reading room
    • Educational process in IT
    • Research and forecasts in IT
    • Finance in IT
    • Hakatonas
    • IT emigration
    • Education abroad
    • Lumber room
    • I'm on my way

Algorithm operation protocol ssh

 
3r3-31. Periodically reading articles on SSH, I noticed that their authors sometimes have no idea how this protocol works. In most cases, they are limited to considering the topic of key generation and the description of options for the main commands. Even experienced system administrators often carry a total nonsense when discussing SSH operation issues, giving out opus in the style: the transmitted data is encrypted with the client's open SSH key, and decrypted with a private one, or: the RSA algorithm is used to encrypt data during transmission.
 
 
I will try to bring some clarity to the operation of the SSH protocol, and at the same time consider the role of the RSA algorithm and user authorization keys
 
 
Algorithm operation protocol ssh
 
3r33333.
 
 
The SSH protocol algorithm can be divided into three levels, each of which is located above the previous one: transport (opening a secure channel), authentication, connection. For the integrity of the picture, I will also add the network connection setup level, although officially this level is below SSH.
 
 
3r3-3160. 1. Establish a TCP connection
 
I will not dwell on the principle of operation of the TCP /IP stack, since this topic is well documented in RuNet. If necessary, you can easily find information.
 
 
At this stage, the client connects to the server on the TCP port specified in the Port option (default: 22) in the server configuration file /etc /ssh /sshd_config.
 
 
3r3-3160. 2. Open the secure channel 3r3161.
 
2.1 Identity Exchange
 
 
After the TCP connection is established, the client and the server (hereinafter referred to as the parties) exchange versions of the SSH protocol and other auxiliary data necessary for determining the compatibility of the protocols and for selecting the operation algorithms.
 
 
[b] 2.2 Selection of algorithms: key exchange, encryption, compression, etc. 3r3386.
 
 
When SSH is used, quite a few algorithms are used, some of them are used for encryption, the second for key exchange, the third for compressing transmitted data, etc. At this step, the parties send each other lists of supported algorithms, the highest priority is given to the algorithms at the top of each list. Then they compare the algorithms in the received lists with the algorithms available in the system and select the first matched one in each list.
 
 
The list of available client-side key exchange algorithms (used to obtain a session key) can be viewed with the command: 3r3326.  
3r31-10. ssh -Q kex 3r33112.
 
The list of symmetric algorithms available in the system (used to encrypt the channel): 3r3326.  
3r31-10. ssh -Q cipher 3r33112.
 
The list of key types for authorization at the client:
 
3r31-10. ssh -Q key-cert 3r33112.
 
 
[b] 2.3 Getting a session encryption key 3r3386.
 
 
The process of obtaining a session key may differ depending on the version of the algorithm, but in general terms it comes down to the following: 3r3326.  
 
 
The server sends its key to the client (DSA, RSA, or the like, according to the agreement between the parties made in clause 2.2). 3r33333.  
If the client connects to this server for the first time (as indicated by the absence of an entry in the /home/username/.ssh/known_hosts file at the client), then the user will be asked to trust the server key. If the connection with this server has already been established, then the client compares the sent key with the key recorded in /home/username/.ssh/known_hosts. If the keys do not match, the user will receive a warning about a possible hacking attempt. However, this check can be skipped if you call ssh with the StrictHostKeyChecking option:
 
3r31-10. ssh -o StrictHostKeyChecking = no username @ servername 3r33112. Also, if the user needs to delete the old server key (for example, when there is an exact certainty that the key has been changed on the server), the command is used:
 
3r31-10. ssh-keygen -R servername 3r33112.
 
3r33333.  
As soon as the client decides that the server key is trusted, using one of the implementations (the version is defined in clause 2.2) of the Diffie-Hellman algorithm, the client and server generate a session key that will be used for symmetric channel encryption.
 
3r33333.  
3r33333.
 
The session key is created exclusively for the period of the channel's life and is destroyed when the connection is closed.
 
 
3r3-3160. 3. Client Authentication
 
And only now, when the client and the server have established a channel for encrypted data transfer, can they authenticate with a password or key.
 
 
In general terms, authentication using keys is as follows:
 
 
 
The client sends the username (username) and its public key to the server. 3r33333.  
The server checks in the file /home/username/.ssh/authorized_keys the presence of the public key sent by the client. If the public key is found, the server generates a random number and encrypts it with the client's public key, after which the result is sent to the client. 3r33333.  
The client decrypts the message with its private key and sends the result to the server. 3r33333.  
The server checks the result for a match with the number that it originally encrypted with the client’s public key, and if a match occurs, it considers the authentication successful. 3r33333.  
3r33333.
 
 
3r3-3160. 4. Connection level 3r3161.
 
After carrying out all the above procedures, the user is able to send commands to the server or copy files.
 
 
At this level, the following is provided: channel multiplication (the ability of multiple channels to work on a single server by combining them into one channel), tunneling, etc.
 
 
From theory to practice 3r3-3325.
 
Well, now, I think, the readers have quite a legitimate question: why do we need to know all these subtleties of the SSH protocol, if for everyday work there is enough knowledge of the key creation commands (ssh-keygen), opening a terminal session (ssh), file transfer ( scp)?
 
 
As a response, you can recall the topic of changing the standard SSH port to another one, which constantly becomes the cause of holivar on Habr 3r3326.  
 
In my own practice, I don’t remember a single server looking to the external network that would not be daily slapped to port 22. In a situation if SSH works on a standard port for you (and is not additionally protected by anything), even if authentication using keys only and no password selections do not frighten you, the server is still forced to do a lot of useless work because of constant requests from unscrupulous clients: establish a TCP connection, select algorithms, generate a session key, send authentication requests, write a log file.
 
 
In a situation where there is nothing on port 2? or the port is protected using iptables (or add-ons of the fail2ban type), the attacker will be dropped at the stage of establishing a TCP connection.
 
 
The most interestingly described looks like a table *
 
3r3194.  
 
3r3204. Configuration 3r3205.  
3r3204. The probability of breaking
 
3r3204. Losses from flooding **
 
3r3309.  
 
3r3306. Port 2? 3r3326.  
password authentication,
 
without protection 3r3307.  
3r3306. high 3r3307.  
3r3306. high 3r3307.  
3r3309.  
 
3r3306. Port 2? 3r3326.  
key authorization,
 
without protection 3r3307.  
3r3306. average *** 3r3307.  
3r3306. high 3r3307.  
3r3309.  
 
3r3306. Port 2? 3r3326.  
key authorization,
 
protection based on limiting failed authorization attempts 3r3307.  
3r3306. low 3r3307.  
3r3306. average **** 3r3307.  
3r3309.  
 
3r3306. Custom port,
 
password authentication,
 
without protection 3r3307.  
3r3306. high 3r3307.  
3r3306. low 3r3307.  
3r3309.  
 
3r3306. Custom port,
 
key authorization,
 
without protection 3r3307.  
3r3306. average *** 3r3307.  
3r3306. low 3r3307.  
3r3309.  
 
3r3306. Custom port,
 
key authorization,
 
protection based on limiting failed authorization attempts 3r3307.  
3r3306. low 3r3307.  
3r3306. low 3r3307.  
3r3309.  
3r33311.
 
* - the values ​​of the parameters (high, medium, low) are of a relative nature and serve only to compare indicators.
 
** - meaning the consumption of server resources (processor, disk, network channel, etc.) for processing an avalanche of requests, usually going to port 22.
 
*** - hacking, if RSA-keys are used for authorization, is very difficult, but an unlimited number of authorization attempts makes this possible.
 
**** - the number of authentication attempts is limited, but the server still has to handle them from a large number of intruders.
 
 
Additional materials 3r3325.
 
 
3r33333. SSH sources
3r33333.  
3r33336. SSH protocol specifications (en)
3r33333.  
3r33333. Diffie-Hellman algorithm
3r33333.  
3r33333. Algorithm RSA
3r33333.  
3r33351. How SSH appeared on port 22 3rr3362. 3r33333.  
3r33356. What is written in the .ssh /known_hosts file
3r33333.  
3r33333. Memo to ssh users
3r33333.  
3r33333.
3r33333. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d,! 1): e.attachEvent ("onload", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () ();

It may be interesting

  • Comments
  • About article
  • Similar news
This publication has no comments.

weber

Author

9-10-2018, 08:30

Publication Date

Server Administration / Information Security

Category
  • Comments: 0
  • Views: 316
TLS and Web Certificates
Streaming video through the browser
Implementation of the new transport
The certification of WPA3 devices
Installation icecast2 server with SSL
Fundamentals of cryptography. Part 0
Write a comment
Name:*
E-Mail:


Comments
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post.Torrance Tax Accountant

Today, 15:51

raymond weber

Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The way of writing is excellent and also the content is top-notch. Thanks for that insight you provide the readers! 123movies websites 
Today, 15:21

Legend SEO

Extremely intriguing online journal. A lot of web journals I see nowadays don't generally give anything that I'm keen on, however I'm most definitely inspired by this one. Recently felt that I would post and let you know.먹튀

Today, 15:14

raymond weber

Man's lives, such as uncontrolled huge amounts, definitely not while countries furthermore reefs, challenging to seismic disturbance upward perfect apply. เมล็ด กาแฟ คั่ว
Today, 14:54

nushra45

 The top five occupations were all medical and surgical jobs where workers ... as of May 2019, the most recent period for which data is available.


https://iptvbeast.net/
Today, 14:53

Jhon Smith

Adv
Website for web developers. New scripts, best ideas, programming tips. How to write a script for you here, we have a lot of information about various programming languages. You are a webmaster or a beginner programmer, it does not matter, useful articles will help to make your favorite business faster.

Login

Registration Forgot password