**The Magic of SSH: Unlocking Secure Remote Access**
SSH, or Secure Shell, is a protocol that enables secure remote access to a computer over the internet. It's not just a way to connect to a shell; it's an entire suite of features and tools that allow users to securely access and control remote machines. In this article, we'll delve into the world of SSH and explore its many layers, features, and capabilities.
**Encrypting Data**
When you establish a connection with an SSH server, it encrypts the data being transmitted. The client sends encrypted packets to the server, which then decrypts them. This process is repeated in reverse, allowing the client to receive decrypted packets and extract the original data. This encryption is what makes SSH secure; it ensures that even if someone intercepts the data, they won't be able to read or understand it.
**Multiplexing Multiple Connections**
One of the key features of SSH is its ability to multiplex multiple connections over a single connection. When you establish a connection with an SSH server, it creates a new channel for each subsequent command or interaction. This allows users to have multiple connections open at the same time, making it easier to manage and automate tasks on remote machines.
**Forwarding TCP Connections**
SSH also allows users to forward any type of TCP connection over the SSH tunnel. This means that you can connect to a remote service via the SSH tunnel, and all traffic will be encrypted as it passes through. This feature is particularly useful when connecting to services behind firewalls or other security measures.
**Authentication**
When you attempt to connect to an SSH server, it authenticates your identity before allowing access to the shell. The authentication process involves exchanging information with the server about your compatibility, encryption mechanisms, and more. If the authentication succeeds, the server creates a new channel for your interactive session, allowing you to communicate with the remote machine securely.
**Channel Creation**
When a channel is created in SSH, it's essentially a new connection that allows data to be sent between the client and server. The channel is used to send packets of data wrapped up inside the SSH package, which are then decrypted at the receiving end. This process enables users to interact with the remote machine as if they were sitting in front of it.
**Reusing Existing Connections**
One of the benefits of using SSH is that it can reuse existing connections when multiple connections are made over the same tunnel. This means that even after you've finished a task on a remote machine, you can still use the same connection to perform other tasks, reducing the need for new connections and minimizing latency.
**Security and Convenience**
SSH's security features make it an essential tool for anyone who needs to access remote machines securely. By encrypting data in transit and authenticating users before allowing access, SSH provides a robust layer of protection against eavesdropping and unauthorized access. At the same time, its ease of use and flexibility make it a convenient choice for both beginners and experienced users.
**New Discoveries**
Despite being around for over 20 years, SSH continues to evolve and reveal new features and capabilities. Its ability to keep connections alive beyond initial disconnection and reuse existing channels are just two examples of the many ways in which SSH is used today. As technology advances, it's likely that we'll see even more innovative uses for this powerful protocol.
**The Power of SSH**
In conclusion, SSH is a powerful protocol that offers a wide range of features and capabilities for secure remote access. Its ability to encrypt data, multiplex multiple connections, forward TCP connections, authenticate users, create channels, and reuse existing connections make it an essential tool for anyone who needs to access remote machines securely. Whether you're a beginner or an experienced user, SSH has something to offer, and its continued evolution ensures that it will remain a cornerstone of secure remote access for years to come.
"WEBVTTKind: captionsLanguage: enso we did a video a while back on the scp exploiting the superior copy and i thought it would be just sort of interesting to talk have a look in a bit more detail how ssh works ssh stands for secure shell and it first appeared in the mid 90s as a sort of replacement for way of connecting to a remote machine over the internet up until that time the technologies you had to connect to a remote machine telnet our login rsh and so on worked fine but they transmitted all the data in the clear over the network so if you log into a remote machine anyone with a packet sniffer between you and the remote machine could see everything you were doing on there when these protocols first appear that wasn't a problem because the machines were probably only networked within the computer department of a university or a company so the people who had access to do that were people who worked there and probably the system administrators who had access to these things anyway but as the machines got networked to other networks and you started to build the internet if you had access to the network any network that the data was traveling over you could sniff the packets and see any of the data was being transmitted including passwords and things and so in 1995 tattoo union in finland i apologize if i pronounced that wrongly was concerned about this so he developed a protocol ssh secure shell to sort of encrypt the data so that you couldn't sort of see how what was being sent over the wire you could see the data was being transmitted across you could see how much data you could see the frequency of it to certain extent but you couldn't see what the data was so you could do certain types of analysis to see what's happening but you couldn't see the actual data and so ssh was developed as a way of encrypting the connection between two machines but it actually does a lot more than that because when you ssh to another machine the first thing that happens is that you open up a tcp connection between those two machines like any sign of things although it doesn't have to be a tcp connection you can actually specify that ssh uses any sort of reliable network connection to make that so you could theoretically run it over an rs232 connection you could run it over the top of web sockets and things like that and i know people who have done that sort of thing so you've got a reliable transport between the two machines and so ssh is sending data over there and what ssh does is it breaks the data down into a series of packets and just like any package transfer these things have a few fields at the beginning so at the top you have something that tells you how big the packet is so you have the packet length there four bytes saying the packet is this big after that you have another bite which tells you how much padding you've got so you've got the the packet length you've got how much padding there is and then you've got the the data you want the payload then you have the padding that follows that and so what you do with each package after the payload the data you want to send that's part of the connection you add a small amount of padding just random bytes they don't mean anything but they sort of force the encryption to sort of make it harder to detect what's going on because you've got random data in there see some of mike's videos for more details on why you want to do that and then you have some sort of message authentication code there so you know that the data here hasn't been monkeyed around with but it's actually what was sent you can then apply compression if you want to to that the payload so you can compress the payload using standard compression algorithms such as said zlib or something to compress the data and then the whole of that packet excluding the length is then encrypted the algorithms used for the encryption and for the message authentication code are selected by the server and the client they establish that at the beginning which ones they offer which ones they want to use and things so that they're established um by the client in the server so they vary for connection to connection and you can offer many and you choose the one that's perhaps best for that connection we'll ignore that for the purposes of this video so we leave the packet length unencrypted because obviously we need to know how much data is coming we encrypt the padding length we encrypt the payload we encrypt the padding and we send the packet out over there look at the other end that's decrypted by the server and it then knows it's got the packet of data and you can piece it back together and then the same thing is done for this packet and this packet in every packet and the encryption is done so it's continuous you start encrypting this one within vectors from this one and so on so it sort of encrypts it one after the other at the server or the client which receives this you just reverse that process so you decrypt the packets you decompress the payload and you can extract the data and sort of stitch it back together so you start off you've got your tcp connection and that's unencrypted and on top of that you've got these packets which have been encrypted by the ssh protocol flowing on top of that but that's not the end of the story that's just encrypting the packets it's that's not the connection that say if you restoration that's not your connection to the remote machine on top of that you then open a series of channels that you send the data over and the reason for that is it enables you to multiplex multiple connections over that thing so when i start a connection to my machine it's creating a channel on top of this so this is our one computer over here and this is another one over here we're creating this channel here for our shell connection where we can communicate and control things but this is actually being represented by a connection through the ssh packets and we could have multiple ones of these between the same machines or we could have different types of connections so for example ssh also allows you to forward any sort of tcp connection over there so you can connect to a remote service via the ssh tunnel so you can tunnel that through and it's encrypted and then sent out at the other end and if we make the connection with verbose mode on we can actually see it's setting up that connection so what we've got here it's reading the configuration data its local protocol string is so it connects to the remote machine it sends back saying i support this version of ssh i've sent what my version is we've then exchanged information about our compatibility what mechanisms we use for encrypting the messages the packets over the network and so on we've checked that we know the machine and then we get down to here we're now trying to authenticate so it's now establishing okay this is this user on that machine so i could put my password in and we're now connected but if we look here authentication succeeded we're authenticated to the remote machine and you see here it's creating a new channel so it's creating a connection which again is just going to be i send bytes down here they appear at the other end we send bytes the other way they come back to us over this channel and you send setting up what type of connection is it's setting environment variables and things and this is done by sending packets of data wrapped up inside the ssh package which established that once that's done we can then communicate and have our interactive session so ssh is not just a sort of way of connecting a shell it's actually got layers of things on top of that which enable you to do lots of interesting things so you can have multiple connections made over this thing you don't just have to have one and there's ways that you can set ssh up so actually you make the connection and it stays connected when you finish so if you then make another connection to the same server it reuses that existing connection and multiplexes the two connections in between things it can start and stop forwarded tcp connections to other addresses in both directions while the connection's running just by sending different things over this connection the reason why it's got all this functionality is that often particularly in the unix environment or the linux environment when you're connecting to other machines you may just want a remote shell connection wait for the type commands and do things that's great but also the way the unix x windows graphical user interface works is that has a normally done over a connection usually tcp ip to port 6000 although it can be done over other things as well and so that could then be forwarded into the connection so that you could log in to another machine and send the graphics commands back encrypted as well um occasionally you may want to connect to a service behind a firewall and you can do that by tunneling it through the ssh connection so there's lots of reasons why it was built this way but it it's a nice feature and i know i've been using this now for 20 odd years 24 years probably um now but actually you're still discovering new things you can do with it for example the fact you can keep a connection alive beyond when you've just you've disconnected from the shell so they can reuse that tcp connection the lower level bits when you create a new connection on top the more people you add to this group so maybe you're a member of some kind of school thing 50 people in the group you're sending 50 messages right and if you're not sending a text message maybe you're sending a video suddenly the bandwidth becomes actually a bit of a problem a snake robot is performing uh sidewinding let's give it a little boost for speedso we did a video a while back on the scp exploiting the superior copy and i thought it would be just sort of interesting to talk have a look in a bit more detail how ssh works ssh stands for secure shell and it first appeared in the mid 90s as a sort of replacement for way of connecting to a remote machine over the internet up until that time the technologies you had to connect to a remote machine telnet our login rsh and so on worked fine but they transmitted all the data in the clear over the network so if you log into a remote machine anyone with a packet sniffer between you and the remote machine could see everything you were doing on there when these protocols first appear that wasn't a problem because the machines were probably only networked within the computer department of a university or a company so the people who had access to do that were people who worked there and probably the system administrators who had access to these things anyway but as the machines got networked to other networks and you started to build the internet if you had access to the network any network that the data was traveling over you could sniff the packets and see any of the data was being transmitted including passwords and things and so in 1995 tattoo union in finland i apologize if i pronounced that wrongly was concerned about this so he developed a protocol ssh secure shell to sort of encrypt the data so that you couldn't sort of see how what was being sent over the wire you could see the data was being transmitted across you could see how much data you could see the frequency of it to certain extent but you couldn't see what the data was so you could do certain types of analysis to see what's happening but you couldn't see the actual data and so ssh was developed as a way of encrypting the connection between two machines but it actually does a lot more than that because when you ssh to another machine the first thing that happens is that you open up a tcp connection between those two machines like any sign of things although it doesn't have to be a tcp connection you can actually specify that ssh uses any sort of reliable network connection to make that so you could theoretically run it over an rs232 connection you could run it over the top of web sockets and things like that and i know people who have done that sort of thing so you've got a reliable transport between the two machines and so ssh is sending data over there and what ssh does is it breaks the data down into a series of packets and just like any package transfer these things have a few fields at the beginning so at the top you have something that tells you how big the packet is so you have the packet length there four bytes saying the packet is this big after that you have another bite which tells you how much padding you've got so you've got the the packet length you've got how much padding there is and then you've got the the data you want the payload then you have the padding that follows that and so what you do with each package after the payload the data you want to send that's part of the connection you add a small amount of padding just random bytes they don't mean anything but they sort of force the encryption to sort of make it harder to detect what's going on because you've got random data in there see some of mike's videos for more details on why you want to do that and then you have some sort of message authentication code there so you know that the data here hasn't been monkeyed around with but it's actually what was sent you can then apply compression if you want to to that the payload so you can compress the payload using standard compression algorithms such as said zlib or something to compress the data and then the whole of that packet excluding the length is then encrypted the algorithms used for the encryption and for the message authentication code are selected by the server and the client they establish that at the beginning which ones they offer which ones they want to use and things so that they're established um by the client in the server so they vary for connection to connection and you can offer many and you choose the one that's perhaps best for that connection we'll ignore that for the purposes of this video so we leave the packet length unencrypted because obviously we need to know how much data is coming we encrypt the padding length we encrypt the payload we encrypt the padding and we send the packet out over there look at the other end that's decrypted by the server and it then knows it's got the packet of data and you can piece it back together and then the same thing is done for this packet and this packet in every packet and the encryption is done so it's continuous you start encrypting this one within vectors from this one and so on so it sort of encrypts it one after the other at the server or the client which receives this you just reverse that process so you decrypt the packets you decompress the payload and you can extract the data and sort of stitch it back together so you start off you've got your tcp connection and that's unencrypted and on top of that you've got these packets which have been encrypted by the ssh protocol flowing on top of that but that's not the end of the story that's just encrypting the packets it's that's not the connection that say if you restoration that's not your connection to the remote machine on top of that you then open a series of channels that you send the data over and the reason for that is it enables you to multiplex multiple connections over that thing so when i start a connection to my machine it's creating a channel on top of this so this is our one computer over here and this is another one over here we're creating this channel here for our shell connection where we can communicate and control things but this is actually being represented by a connection through the ssh packets and we could have multiple ones of these between the same machines or we could have different types of connections so for example ssh also allows you to forward any sort of tcp connection over there so you can connect to a remote service via the ssh tunnel so you can tunnel that through and it's encrypted and then sent out at the other end and if we make the connection with verbose mode on we can actually see it's setting up that connection so what we've got here it's reading the configuration data its local protocol string is so it connects to the remote machine it sends back saying i support this version of ssh i've sent what my version is we've then exchanged information about our compatibility what mechanisms we use for encrypting the messages the packets over the network and so on we've checked that we know the machine and then we get down to here we're now trying to authenticate so it's now establishing okay this is this user on that machine so i could put my password in and we're now connected but if we look here authentication succeeded we're authenticated to the remote machine and you see here it's creating a new channel so it's creating a connection which again is just going to be i send bytes down here they appear at the other end we send bytes the other way they come back to us over this channel and you send setting up what type of connection is it's setting environment variables and things and this is done by sending packets of data wrapped up inside the ssh package which established that once that's done we can then communicate and have our interactive session so ssh is not just a sort of way of connecting a shell it's actually got layers of things on top of that which enable you to do lots of interesting things so you can have multiple connections made over this thing you don't just have to have one and there's ways that you can set ssh up so actually you make the connection and it stays connected when you finish so if you then make another connection to the same server it reuses that existing connection and multiplexes the two connections in between things it can start and stop forwarded tcp connections to other addresses in both directions while the connection's running just by sending different things over this connection the reason why it's got all this functionality is that often particularly in the unix environment or the linux environment when you're connecting to other machines you may just want a remote shell connection wait for the type commands and do things that's great but also the way the unix x windows graphical user interface works is that has a normally done over a connection usually tcp ip to port 6000 although it can be done over other things as well and so that could then be forwarded into the connection so that you could log in to another machine and send the graphics commands back encrypted as well um occasionally you may want to connect to a service behind a firewall and you can do that by tunneling it through the ssh connection so there's lots of reasons why it was built this way but it it's a nice feature and i know i've been using this now for 20 odd years 24 years probably um now but actually you're still discovering new things you can do with it for example the fact you can keep a connection alive beyond when you've just you've disconnected from the shell so they can reuse that tcp connection the lower level bits when you create a new connection on top the more people you add to this group so maybe you're a member of some kind of school thing 50 people in the group you're sending 50 messages right and if you're not sending a text message maybe you're sending a video suddenly the bandwidth becomes actually a bit of a problem a snake robot is performing uh sidewinding let's give it a little boost for speedso we did a video a while back on the scp exploiting the superior copy and i thought it would be just sort of interesting to talk have a look in a bit more detail how ssh works ssh stands for secure shell and it first appeared in the mid 90s as a sort of replacement for way of connecting to a remote machine over the internet up until that time the technologies you had to connect to a remote machine telnet our login rsh and so on worked fine but they transmitted all the data in the clear over the network so if you log into a remote machine anyone with a packet sniffer between you and the remote machine could see everything you were doing on there when these protocols first appear that wasn't a problem because the machines were probably only networked within the computer department of a university or a company so the people who had access to do that were people who worked there and probably the system administrators who had access to these things anyway but as the machines got networked to other networks and you started to build the internet if you had access to the network any network that the data was traveling over you could sniff the packets and see any of the data was being transmitted including passwords and things and so in 1995 tattoo union in finland i apologize if i pronounced that wrongly was concerned about this so he developed a protocol ssh secure shell to sort of encrypt the data so that you couldn't sort of see how what was being sent over the wire you could see the data was being transmitted across you could see how much data you could see the frequency of it to certain extent but you couldn't see what the data was so you could do certain types of analysis to see what's happening but you couldn't see the actual data and so ssh was developed as a way of encrypting the connection between two machines but it actually does a lot more than that because when you ssh to another machine the first thing that happens is that you open up a tcp connection between those two machines like any sign of things although it doesn't have to be a tcp connection you can actually specify that ssh uses any sort of reliable network connection to make that so you could theoretically run it over an rs232 connection you could run it over the top of web sockets and things like that and i know people who have done that sort of thing so you've got a reliable transport between the two machines and so ssh is sending data over there and what ssh does is it breaks the data down into a series of packets and just like any package transfer these things have a few fields at the beginning so at the top you have something that tells you how big the packet is so you have the packet length there four bytes saying the packet is this big after that you have another bite which tells you how much padding you've got so you've got the the packet length you've got how much padding there is and then you've got the the data you want the payload then you have the padding that follows that and so what you do with each package after the payload the data you want to send that's part of the connection you add a small amount of padding just random bytes they don't mean anything but they sort of force the encryption to sort of make it harder to detect what's going on because you've got random data in there see some of mike's videos for more details on why you want to do that and then you have some sort of message authentication code there so you know that the data here hasn't been monkeyed around with but it's actually what was sent you can then apply compression if you want to to that the payload so you can compress the payload using standard compression algorithms such as said zlib or something to compress the data and then the whole of that packet excluding the length is then encrypted the algorithms used for the encryption and for the message authentication code are selected by the server and the client they establish that at the beginning which ones they offer which ones they want to use and things so that they're established um by the client in the server so they vary for connection to connection and you can offer many and you choose the one that's perhaps best for that connection we'll ignore that for the purposes of this video so we leave the packet length unencrypted because obviously we need to know how much data is coming we encrypt the padding length we encrypt the payload we encrypt the padding and we send the packet out over there look at the other end that's decrypted by the server and it then knows it's got the packet of data and you can piece it back together and then the same thing is done for this packet and this packet in every packet and the encryption is done so it's continuous you start encrypting this one within vectors from this one and so on so it sort of encrypts it one after the other at the server or the client which receives this you just reverse that process so you decrypt the packets you decompress the payload and you can extract the data and sort of stitch it back together so you start off you've got your tcp connection and that's unencrypted and on top of that you've got these packets which have been encrypted by the ssh protocol flowing on top of that but that's not the end of the story that's just encrypting the packets it's that's not the connection that say if you restoration that's not your connection to the remote machine on top of that you then open a series of channels that you send the data over and the reason for that is it enables you to multiplex multiple connections over that thing so when i start a connection to my machine it's creating a channel on top of this so this is our one computer over here and this is another one over here we're creating this channel here for our shell connection where we can communicate and control things but this is actually being represented by a connection through the ssh packets and we could have multiple ones of these between the same machines or we could have different types of connections so for example ssh also allows you to forward any sort of tcp connection over there so you can connect to a remote service via the ssh tunnel so you can tunnel that through and it's encrypted and then sent out at the other end and if we make the connection with verbose mode on we can actually see it's setting up that connection so what we've got here it's reading the configuration data its local protocol string is so it connects to the remote machine it sends back saying i support this version of ssh i've sent what my version is we've then exchanged information about our compatibility what mechanisms we use for encrypting the messages the packets over the network and so on we've checked that we know the machine and then we get down to here we're now trying to authenticate so it's now establishing okay this is this user on that machine so i could put my password in and we're now connected but if we look here authentication succeeded we're authenticated to the remote machine and you see here it's creating a new channel so it's creating a connection which again is just going to be i send bytes down here they appear at the other end we send bytes the other way they come back to us over this channel and you send setting up what type of connection is it's setting environment variables and things and this is done by sending packets of data wrapped up inside the ssh package which established that once that's done we can then communicate and have our interactive session so ssh is not just a sort of way of connecting a shell it's actually got layers of things on top of that which enable you to do lots of interesting things so you can have multiple connections made over this thing you don't just have to have one and there's ways that you can set ssh up so actually you make the connection and it stays connected when you finish so if you then make another connection to the same server it reuses that existing connection and multiplexes the two connections in between things it can start and stop forwarded tcp connections to other addresses in both directions while the connection's running just by sending different things over this connection the reason why it's got all this functionality is that often particularly in the unix environment or the linux environment when you're connecting to other machines you may just want a remote shell connection wait for the type commands and do things that's great but also the way the unix x windows graphical user interface works is that has a normally done over a connection usually tcp ip to port 6000 although it can be done over other things as well and so that could then be forwarded into the connection so that you could log in to another machine and send the graphics commands back encrypted as well um occasionally you may want to connect to a service behind a firewall and you can do that by tunneling it through the ssh connection so there's lots of reasons why it was built this way but it it's a nice feature and i know i've been using this now for 20 odd years 24 years probably um now but actually you're still discovering new things you can do with it for example the fact you can keep a connection alive beyond when you've just you've disconnected from the shell so they can reuse that tcp connection the lower level bits when you create a new connection on top the more people you add to this group so maybe you're a member of some kind of school thing 50 people in the group you're sending 50 messages right and if you're not sending a text message maybe you're sending a video suddenly the bandwidth becomes actually a bit of a problem a snake robot is performing uh sidewinding let's give it a little boost for speed\n"