Mac os enable ssh

How to Enable SSH on Mac from the Terminal

The world is quickly filling up with smarter people who search for smarter ways to work. In this world of smarter brains, working on multiple locations from a single place is a small thing. Many professionals are using remote login protocols to work on multiple machines right from their notebooks. Modern Mac books come with SSH pre-installed but not enabled by default. But you can enable SSH on Mac from the terminal quite easily.

SSH (Secure Shell) is an encrypted remote login protocol used to connect to remote machines over the network. This protocol encrypts communication from an end-to-end server and client machines. SSH protocol is preinstalled by default in all modern Macbooks but the daemon is disabled by default. Mac users can simply enable SSH on Mac using simple terminal commands. You can enable SSH on all versions of macOS and Mac OS X by using the below tutorial.

Check SSH status on Mac

Before we start, let’s check the current status of SSH on your Macbook. You can do this by using the system setup command below:

sudo systemsetup -getremotelogin

If the remote login and SSH is currently enabled, the output will say “Remote Login: On” If SSH is disabled, it will say “Remote Login: Off”.

How to Enable SSH on Mac from Terminal

  1. Open the terminal on your Mac.
  2. You need administration privileges to enable SSH on your Macbook. Use the below system setup command to enable SSH on Mac:
  3. There won’t be any confirmation message for the above command. So, you need to check the SSH status using the “getremotelogin” command:
  4. Now you can remote login to another machine using its IP address:
  5. You need to provide authentication of the user “technastic” on the machine “eagle.example.com”

How to Disable SSH on Mac from Terminal

If you feel that you no longer use SSH on your machine, then you can simply turn it off to avoid unauthorized access. You can simply disable SSH on your Mac using the below command:

You’ll be asked for confirmation to disable the SSH “Do you really want to turn remote login off? If you do, you will lose this connection and can only turn it back on locally on the server (yes/no)?” Type “yes” to confirm.

Let us know if you have queries in the comments section below. Do you know about all 3 methods to take a screenshot on your Mac computer? Read our detailed guide.

Источник

Enable Remote Login to Start SSH Server in Mac OS X

Remote Login is a feature in Mac OS X’s Sharing preferences that allow remote users to connect to a Mac in a secure fashion by using the OpenSSH protocols. Essentially, Remote Login starts an SSH server on a Mac, which includes the ability to accept incoming SSH connections, and is the secure replacement for telnet. Additionally, this feature includes and enables the SFTP server, which is the secure replacement for FTP, and finally it also enables SCP, for secure remote copying of files. If this sounds complicated or confusing, it’s really not, and we’ll walk through exactly how to quickly enable and set up the SSH server on a Mac so that it can accept inbound secured ssh, sftp, and scp connections.

How to Enable SSH & SFTP Server in Mac OS X with Remote Login

By starting the “Remote Login” service, you enable SSH and SFTP servers in Mac OS X. These instructions are the same for enabling remote login and accompanying SSH servers in MacOS Mojave 10.14, MacOS High Sierra 10.13, macOS Sierra 10.12, OS X El Capitan 10.11, Yosemite 10.10, OS X Mavericks 10.9, 10.8 Mountain Lion, 10.7 Lion, and 10.6 Snow Leopard.

  1. Open System Preferences from the  Apple menu, and click on the “Sharing” preference panel
  2. Select the checkbox next to “Remote Login” to enable it, like the screenshot indicates

Clicking the checkbox will instantly start the various remote login servers, including sftp and ssh.

Читайте также:  Bcm43142ao драйвер для windows 10

If you want to limit incoming SSH access to certain users, you can do so in the same preference panel by ticking “Only these users” and then manually adding them by clicking on the + icon. This brings up a list of Users & Groups on the Mac that you can select from. Think of this as an extra security step, although SSH by default is quite secure as is due to the nature of the protocol.

Now that the SSH server has been enabled, you can verify they have enabled if you’d like. The easiest way to do this is to visit Terminal app and type either ‘ssh localhost’ or ‘sftp localhost’, which, if all is running as intended, should return something like this:

$ sftp localhost
The authenticity of host ‘localhost (::1)’ can’t be established.
RSA key fingerprint is b3:42:27:4a:b6:22:86:4b:c6:21:32:47:4b:8b:18:0d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘localhost’ (RSA) to the list of known hosts.
Password:

Connecting to localhost isn’t too useful though, and this is called Remote Login for a reason, because it allows for secured connections to remote Macs through either the SSH command line interface, SFTP through any modern FTP/SFTP client, or with a direct file transfer by using the scp command from the terminal of other Macs or unix machines. We’ll focus primarily on the SSH and SFTP side of things because that is generally what the most commonly needed.

Connecting to the Mac SSH Server Remotely

Now that you have SSH up and running, connecting to it remotely is easy. The great thing about this is you can now connect to the Mac from virtually any other operating system, all you need is an SSH client. SSH clients are bundled with Mac OS X and Linux so there are no downloads necessary there, you can just open the Terminal and use the ‘ssh’ commands, but iOS users can use Prompt and Windows users can get PuTTY (its free).

1) From the Mac functioning as an SSH Server:

First you’ll want to grab the IP of the Mac running the server, this let’s another user/client know where to connect to:

  • Get the Macs IP address – Go to “System Preferences” and “Network” to retrieve the IP

2) Connecting to the Mac with SSH from another computer:

Now with servers IP address, the Mac can be connected to:

    We’ll assume you’re using the Terminal in Mac OS X, so using the IP address that you just found, use the following command syntax:

This is what it would actually look like, using paul as the username and 192.168.0.25 as the server IP:

  • You will be asked to accept an RSA key to your known hosts list, so type “yes” and then you will be asked for the users password
  • You’re now remotely connected to the Mac via SSH
  • You’ll now be logged into the Mac through SSH, this can be done remotely or over a local network, and all traffic to and from the machines is securely encrypted.

    Terminal savvy users might also find it useful to know that you can enable and disable SSH server from the Mac command line as discussed here.

    Connect to the Mac through SFTP

    Because Remote Login enables both SSH and SFTP, you can also now connect to the Mac securely through the sftp protocol. This can be done through the Terminal, or through third party SFTP apps like CyberDuck, Transmit, Filezilla, or even from Mac OS X itself to transfer files to and from the Mac from any other location. A direct SFTP service link would look something like this: sftp://192.168.0.100

    From the Terminal and command line, you would use the following command syntax to connect to the SFTP server:

    If you want to use SCP instead, the procedure is the same except you use ‘scp’ as the commands instead.

    A few things to remember here: your local IP address (on a LAN) is different than your external IP address (to the outside world). The easiest way to get a machines external IP is by going to a site like ‘whatismyip.org’ but keep in mind that if the Mac is behind a router with a firewall, you would have to open the ports on the router to be able to access it. That process is different depending on the router and firewall in use, so it wouldn’t make much sense to cover it here.

    Finally, breaking away from Mac OS X and going to the mobile world with iOS, you can actually SSH into iPhones and iPads too by setting up servers on iOS devices too, but it’s a bit more complicated and requires a jailbreak to be able to enable the servers and gain access to the iOS command line.

    The inclusion of SSH, and thereby SFTP, through Remote Login also explains why Apple ditched the FTP server in Lion onward onward (this remains the same in Mojave, High Sierra, Sierra, El Capitan, Yosemite, Mavericks, and Mountain Lion, though you can still install ftp if you really need to through Homebrew or by compiling it yourself), as they opted for the infinitely more secure and encrypted SSH and SFTP options, and bundled it within Sharing’s “Remote Login” option as part of the entire SSH package.

    Читайте также:  Просмотрщик dwg файлов для mac os

    Thanks to Izdexic for the post idea via comments

    If you have any helpful tips or information pertaining to SSH on a Mac, share with us in the comments below!

    Источник

    How to SSH on Mac with the Native SSH Client

    Did you know the Mac has a native SSH client built directly into the command line? This ssh client allows for secured connections and remote logins into other machines. Unlike Windows, you won’t need a third party app to utilize SSH for connections into remote computers and devices, because ssh is built directly into Mac OS and Mac OS X – perfect!

    Let’s walk through how to make an SSH connection into another computer using the native ssh client in Mac OS.

    Some quick background for the unfamiliar; SSH stands for Secure SHell, and it permits making encrypted connections into other computers over a network or the broader internet. You can use the SSH client in Mac OS to connect to any other machine with an SSH server running, whether it’s on another Mac with Mac OS X, linux, unix, or Windows computer does not matter, as long as it has an SSH server running it and you have credentials, it can be connected to securely.

    Using ssh is considered somewhat advanced and typically useful for remote systems administration, shell activity, server management, and other command line activity. If you have two computers on your own network you can setup an SSH server on a Mac via System Preferences quite easily, or if you’re savvy with Terminal you can enable SSH through the command line too, and try this out for yourself.*

    How to Use the SSH Client on Mac

    Assuming you have the remote server IP and the remote username handy, here’s all you need to do to connect via SSH in Mac OS and Mac OS X:

      Launch the Terminal application, Terminal is found in /Applications/Utilities/ directory but you can also launch it from Spotlight by hitting Command+Spacebar and typing “Terminal” and then return

    At the command prompt, enter the following ssh syntax:

    Replace “username” with the appropriate user account of the remote machine, and “ip.address” with the IP address of the remote machine. For example:

  • Hit the Return key to execute the command
  • Optional: You may need to verify the authenticity of the host, if everything checks out type “yes” to accept a fingerprint key and connect to the SSH server, or type ‘no’ to reject it and disconnect
  • Login to the remote server by entering the password for the user account you are logging into

    That’s it, now you’re logged in to the remote machine via SSH.

    At this point you have access to any command line functionality on the remote computer, assuming you have privileges to perform the task or execute the command. What you do once you’re connected with SSH is up to you, but as state earlier it’s intended for advanced uses like systems administration, server management, network operations, and other higher level tasks that are generally less relevant to the average computer user.

    When you’re finished you can type “exit” to disconnect from the remote machine, or just close the Terminal app to close the ssh client and connection.

    * Side note: you can also SSH into your own Mac this way if you juts want to try this out, but there is little point to that since launching Terminal in and of itself grants you direct shell access to the computer to begin with. But, it does offer a means of experimenting with SSH connections if you have never done so before, just use your username @ localhost or 127.0.0.1 for the IP.

    By the way if you want to allow someone else to remotely SSH into YOUR Mac, you’d need to setup the native SSH server on your Mac (easy as described here) and then you’d want to add a new user account to the Mac for that person, never share your own login and password with anyone else. Keep in mind if you give someone SSH access to your Mac with an admin account, you are giving them full access to your computer, all files, apps, activity, logs, and everything else, representing complete and total remote access to the computer. The command line has a huge number of commands available and is more powerful than the familiar graphical interface (GUI) we all know and love, so you probably do not want to allow for this randomly. Anything you can do at the command line can be done through ssh, assuming appropriate user privileges – this is why it’s so widely used for systems administration and by advanced users, and much less relevant to neophytes and the less technically inclined. If you want to give someone remote access for troubleshooting purposes and you’re a novice, a better approach is to use screen sharing instead.

    Читайте также:  Версия gcc для linux

    Want to see more SSH tips (here)? Do have any fancy SSH tricks you want to share? Do you know of a better SSH client than OpenSSH that is built into Mac OS? Let us know in the comments!

    Источник

    How to Enable SSH on a Mac from the Command Line

    All modern Macs running macOS or Mac OS X come with SSH pre-installed by default, but the SSH (Secure Shell) daemon is also disabled by default. Advanced Mac users may appreciate knowing the ability to enable SSH and disable SSH are both available entirely from the command line of Mac OS, allowing for a simple way to allow or disallow remote connections into a computer. There’s no kext loading, downloads, or compiling necessary, to turn on SSH from the Terminal on any Mac you simply have to execute a system setup command, as we’ll show in this tutorial.

    A quick side note; this guide applies to all versions of macOS and Mac OS X, but is really aimed at more advanced users who spend a lot of time in the Terminal. If you want to toggle SSH off and on and avoid the command line, you can do so by enabling Remote Login in the Sharing preference panel on a Mac, or stop the server by leaving it unchecked. If you do not regularly use ssh, there is no reason to enable the ssh server on a Mac.

    How to Check if SSH Remote Login is Enabled in Mac OS via Terminal

    Want to check the current status of SSH on a Mac? Using the systemsetup command string we can quickly determine if SSH and Remote Login is currently enabled on any Mac:

    sudo systemsetup -getremotelogin

    If remote login and SSH is currently enabled, the command and report will say “Remote Login: On” whereas if SSH is disabled and in the default macOS state, it will say “Remote Login: Off”.

    Enable SSH on Mac from the Command Line with systemsetup

    To quickly turn on SSH server and allow incoming ssh connections to the current Mac, use the -setremotelogin flag with systemsetup like so:

    sudo systemsetup -setremotelogin on

    sudo is necessary because the systemsetup command requires administrator privileges, just like when you enable Remote Login from the Sharing preferences on a Mac to enable the secure shell servers.

    There is no confirmation or message that Remote Login and SSH has been enabled, but you can use the aforementioned -getmorelogin flag to check and verify that SSH server is indeed now running. And yes, using -setremotelogin applies to enabling both ssh and sftp servers on the Mac.

    Once ssh has been enabled, any user account or person who has a login on the current Mac can access it remotely using the ssh command aimed at the Macs IP address like so:

    Once connected, the user will have remote access to the computer via the command line, and if they have an admin account or admin password, they would have full remote administration access as well.

    Turn Off SSH on Mac OS with systemsetup

    If you want to disable SSH servers from the command line and thereby prevent remote connections, simply switch ‘on’ to ‘off’ with the -setremotelogin flag of systemsetup like so:

    sudo systemsetup -setremotelogin off

    Again, sudo is necessary to toggle SSH off and disable the ssh and sftp servers.

    When you successfully execute the command, you will be asked: “Do you really want to turn remote login off? If you do, you will lose this connection and can only turn it back on locally at the server (yes/no)?” so type “yes” to confirm, which will disable SSH and also disconnect any active SSH connections to the Mac in question. If you want to avoid having to type yes/no, perhaps for inclusion in a setup script or otherwise, you can use the -f flag to circumvent the question like so:

    sudo systemsetup -f -setremotelogin off

    Similarly, you can also use -f to skip any prompts in regards to enabling SSH as well.

    systemsetup -f -setremotelogin on

    Do note that whether you turn SSH off or enable SSH from the command line, the Remote Login system preference panel setting in Mac OS X GUI will be adjusted to reflect the change accordingly as well.

    Источник

  • Оцените статью