1729824499

SSH basics


Secure SHell<br> What is ssh? SSH is a secure shell. Lets break that down real quick. A shell is what keeps your kernel separated from the software layer. However it is not just a barrier but rather an interface. With the shell you can issue commands to the underlying kernel to preform actions affecting both the kernel as well as the higher level software running atop it. No one really references it this way. When someone says shell they are referring to the terminal or cmd line of your distribution. Now, everything regarding the shell and its layers are true, however most people just think of it as bash or power shell. As i am on a UNIX based OS, bash is the most common and what I use. It stands for bourne again shell. There are many shell interfaces. Just know that terminal, shell, cli, are all used interchangeably even through differences do exist. The other bit of SSH is secure. All this means is that any device that uses this service will be assured that their connection is secure. There are a multitude of ways to make sure that your cryptographic connection is secure and you are able to configure it with a multitude of cryptographic methods. Put the two of them together and you get ssh. You really only need cryptology if some data is passive over a network and you want to keep it protected from prying eyes, and a shell gives you control over a computer. These 2 working together give us remote access to computers. Ssh is not os specific. its not part of the os at all even though it might be included by default. ssh is part of the internet protocol call family. You are more familiar with HTTP (for web browsing), smtp (for emails), IRC (for instant messaging), ftp (for torrent and p2p networks), and many others. Because ssh is not os specific that means that you can use a ssh application, or launch it from your cli and connect to other computers regardless of what os they run. I can remote into a windows machine from a mac and the other way around with no issues. This is because ssh is a standard, a format of sorts. Just like we have HTTP standards that everyone conforms too, we have ssh standards that require clients and servers to have a universal standard to ensure inter-connectivity. There is no windows exclusive version of this, or with any other party making it a good thing to be aware of, as its usage is among all types of platforms. You are reading this on a computer. That means you are signed in as a user. Even if you are using a public computer with no password, you are still a user. I think on Linux there is a user1000 that's is the default 'user' before any users are made. Once a user is made you generally sign in using those credentials. You many occasionally sign in using root, but that should be less common. Take a look yourself. If you are on a UNIX machine open your cli and paste ```cat /etc/passwd``` . This will list the users on your machine, there will be more then you expected but they all have a task, often on that is very specific and you will probably not directly interact with most of them ever. They handle most of the background tasks that you take for granted. Still they are a user, and therefore you can sign in as them. Yes, you can grab any of these users and use their credentials. This is not recommend as you might goof something up. Anyways the point of this is to get you familiar with users. Users will have different levels of permissions. Most people are probably in the users or admin category. The other one that most are familiar with is root, which is both a permission level as well as the name of a user. You can sign into a user in multiple ways, your are most familiar however with your default login prompt. However if you are on a UNIX machine I want you to try something else. First off make sure that you aren't doing anything on your computer. I don't know what display manager you use so im not going to bother getting all the commands to restart your GUI so just be aware that you will just need to restart your computer after doing this to get back to your desktop unless you know the system ctl cmd to restart your x session, or Wayland depending on what you have. For me to switch, sessions, or instances I press ctrl + alt + fn#. I there isn't a limit to how many instances you can have open, but as my keyboard only has 12 fn keys, thats the furthest ill be going. BTW im not familiar with the technical name of these instances/sessions. Ive always heard them called sessions but please leave a comment if you know their real name. Anyways press your keyboard combo to access a different session. f1 by default is the one that you are on right now. f2 might already be in use by some task depending on your computer so f3 onward is best. Once you reboot your computer or your display, come on back. :) <hr> Hi again. Great so first off. When your computer boots up your system initializes a bunch of processes. one of those is the display manager for session 1, your default user session. when you switch, that new session never had all of the startup procedures done, the display is still sending all the display and GUI data to session f1. that is why when you are in f3 or others you get a shell and that's it. You can sign in using your credentials or using the credentials of another user, such as root. I use my credentials and tada, now i am basically using bash from f1. Most users can be signed into multiple sessions at the same time with no issue. I believe there is a config to limit this, but the reasons to do that would be obscure. Possibly on a shared public or school computer. idk. Comment if you can come up with a good reason. Anyways, ssh lets us remotely open a new session on a host computer from a client computer over the internet. This is mostly used for management. If you would like to give this a try grab any computer and make sure that it is allowing traffic to it. By default most computers will come with ssh installed but mostly with just the client part. You see the ssh standard is split into 2 main parts, the client and the host. If your on a UNIX machine just install openssh server as you will already have client. Most installs will automatically configure the server for you. That means that it will listen for incoming request on port 22. With openssh server not installed, your computer will just reject these type of request. Remember you only need to install the server bit onto the host computer, not the computers you intend to connect from. Clients only need the client bit. If your on windows you should already have the client installed. to get the server bit, you need to go to settings -> apps & features -> manage optional features -> add a feature -> open ssh server. now press super + r and type services.msc. find openssh server and start it. this will open port 22 on your computer. All ssh is done through port 22 by default because of the standards mentioned earlier. Now that you have your host, get on your client machine. you will need to know the ip of your host/server. You can find this by running hostname -I on the host. Once we have that info we can connect. Shh follows this format: $ssh username@ip Simple right? ssh calls the ssh client to start. then we give it the address of the computer that we want to connect too. then we give it the username that we want to sign in as. Yes ik the format goes cmd name ip, but its interpreted as cmd ip then user. make sure you are submitting a user that exist on the host machine, not the user from your client. The first time you do this it will ask to generate a key. This is how your server and client both know that they are talking to each other. You can read more into cryptology later. Just for now a simple understanding is that these 2 keys when put together equal something that both the computers agreed on. If the server/client receives a key, that when evaluated equals something different that means it is a different computer or someone is tampering with your connection. type yes to agree to exchange info, you should only have to do this once per server. Your key is stored within home/.ssh btw if you ever need to change or delete it. Now your computer will ask for the password of the username that you submitted during the initial connection. At this point you are connected, just not logged in. Because ssh is secure shell your password that you submit will be protected. Just like when you switched sessions with ctrl + alt + f3, this secured session will dump you to the home dir of the user you signed in. You may now murmur "im in" from all the movies. <hr> Some other things to try: If your a windows user & this all scares you, use putty. If you use x11 learn how to use Xforwarding, its pretty neat. Yes its possible to ssh from machine 1, into machine 2, into machine 3 etc. If you want to ssh from outside your lan you might wana configure a ddns so you can signin from a name rather then ip. for example. ssh user@domain > ssh user@192.168.0.1 Yes its possible to ssh into yourself, this will just occupy one of your other sessions. I have no idea why you would want to do this.

(0) Comments

Welcome to Chat-to.dev, a space for both novice and experienced programmers to chat about programming and share code in their posts.

About | Privacy | Terms | Donate
[2025 © Chat-to.dev]