Hello everyone in this article on Use SSH on Windows/macOS/Linux. An SSH connection creates a secure connection between two computers. SSH can establish a secure, encrypted connection between the client and the server through this encrypted tunnel. From there, you can easily transfer files between connected computers or run programs and commands that would otherwise require a more complex screen sharing solution. It’s like being right in front of your server in the data center where it resides.
If you ever need to securely connect to a remote computer and reach a command line interface, SSH is the tool for the job. The Secure Shell Protocol (SSH) has been used for decades as a means of remotely connecting to Unix/Linux/BSD machines over insecure connections. SSH works on the traditional client-server principle where a remote user (client) can connect to the server and execute commands as if they were sitting at the machine. SSH is especially useful if you have a server (perhaps on one of the best cheap web hosts) or a Raspberry Pi that you need to control remotely. Since these systems mainly use Linux, it is easy to edit scripts, change important configuration files or even install software remotely.
How to use SSH on Windows/macOS/Linux
Using SSH in Windows
Download and install PuTTY. While Windows has its own command line that can be used with SSH, PuTTY is by far the most accessible means of opening an SSH connection.
Open Putty. The PuTTY interface has a Hostname/IP Address section where we would enter the details of the computer we want to use SSH on.
Enter the appropriate address in the Hostname or IP address field and click Open.
When prompted to confirm the connection, answer yes. When you connect to this system for the first time, you will be asked.
Enter your username and password when prompted. The password is not displayed on the screen, this is normal behavior and a security feature.
You are now in control of the remote machine, all commands are executed using the remote machine.
When you’re done with your SSH session, type exit and press Enter or close the window. It is important to close the SSH session when it is not in use, so that you do not accidentally send commands to it or leave it open in case of an attack on your computer.
Using SSH on Linux
Open Terminal if you are not already at a command prompt. To do this, press CTRL + ALT + T, or you can go to the application menu and search for the “terminal” application.
Use SSH to login to the remote computer using your username and IP address / hostname. For example our user was “pi” and hostname was “smartipi” this is what we would use:
If you are prompted that the SSH connection key is not known, enter yes. This may happen the first time you connect, and you may need to reconnect after entering.
Enter your password when prompted. You won’t see characters while typing.
Press CTRL + D or type “logout” to exit the session.
Using SSH on macOS
Start the terminal by clicking on the terminal icon in the dock.
The end device is ready for use.
Enter the SSH command followed by username@server. In the example below, our user was “pi” and the hostname was “raspberrypi.local”.
At the first prompt to confirm the connection, type yes.
Enter your password when prompted.
When the SSH session is complete, exit with CTRL+D or type exit and press Enter. It is important to close the SSH session when it is not in use, so that you do not accidentally send commands to it or leave it open in case of an attack on your computer.
How to run a command to terminate an SSH connection
Open a terminal/command prompt.
Use SSH to login to the remote machine, add “-t”. at the end of the command, put the command you want to run and press Enter. In our example, we log into the Raspberry Pi and then run the poweroff command to shut down the Pi.
ssh firstname.lastname@example.org -t “sudo poweroff”
Enter the password as required
The remote computer should now log you out and then run the task.
We hope you enjoy our article on using SSH on Windows/macOS/Linux. Like most people, you use your computer to connect to a remote computer to work on projects or access files. Whether you’re using Windows, Linux, or macOS, connecting to a remote computer usually requires opening a command prompt and entering a series of commands.
Originally posted 2022-08-31 06:13:12.