- PuTTY SSH client for Mac OSX — download and tutorial
- Contents
- Using the built-in SSH client in Mac OS X
- Running SSH from the terminal command line
- Running SSH with a graphical user interface
- How to use PuTTY SSH keys with the built-in OpenSSH
- Ported PuTTY for Mac
- Installation using HomeBrew
- Installation using MacPorts
- Alternatives to PuTTY on the Mac
- Quick Introduction to SSH for Mac Admins
- What is SSH?
- Enable SSH access
- Connect with SSH
- Ending it
- SSH Shortcut Files
- Execute Just One Command
- Как включить ssh на mac из командной строки 2021
- Mac SSH Verbindung — Terminal — Tutorial
- Как проверить, включен ли удаленный вход SSH в Mac OS через терминал
- Включить SSH на Mac из командной строки с помощью systemsetup
- Отключите SSH в Mac OS с помощью systemsetup
- How to Enable SSH on a Mac from the Command Line
- How to Check if SSH Remote Login is Enabled in Mac OS via Terminal
- Enable SSH on Mac from the Command Line with systemsetup
- Turn Off SSH on Mac OS with systemsetup
PuTTY SSH client for Mac OSX — download and tutorial
PuTTY for Mac is a port of the Windows version of PuTTY . However, there are many options for SSH clients for Mac, and this page discusses several of them.
Contents
Using the built-in SSH client in Mac OS X
Mac OS X includes a command-line SSH client as part of the operating system. To use it, goto Finder, and selext Go -> Utilities from the top menu. Then look for Terminal. Terminal can be used to get a local terminal window, and also supports SSH connections to remote servers.
Running SSH from the terminal command line
Once you have the terminal window open, you have two alternatives. The first approach is to type ssh hostname or ssh user@hostname into the terminal window. This is more familiar for Linux and Unix users who are used to using a command line.
Running SSH with a graphical user interface
The second option is to select New Remote Connection. from the Shell menu of Terminal. This opens a graphical dialog asking for the host to connect to and the user name. This also allows saving connections. This is recommended for users who are not accustomed to using a command line.
How to use PuTTY SSH keys with the built-in OpenSSH
If you have a PuTTY .ppk format private key and want to use it with the built-in OpenSSH on Mac on the command line or in scripts, you can use the following commands.
First, install PuTTY for Mac using brew install putty or port install putty (see below). This will also install the command-line version of puttygen , the PuTTY key generator tool.
Then, use the following command to convert the .ppk format private key to a standard PEM format private key:
Make sure permissions on the private key file are set properly. It should only be readable by the user that owns it.
You can now use the key for logins from scripts and command line with:
Ported PuTTY for Mac
There is a port of PuTTY for Mac. It can be installed in several ways.
Installation using HomeBrew
If you already have the brew command installed, the best way to install PuTTY is to use the following command:
Installation using MacPorts
PuTTY is readily available via MacPorts. To see how to install MacPorts and PuTTY, see here .
Once you have MacPorts installed, you just need to give this command:
and to add a shortcut on the Desktop,
Alternatives to PuTTY on the Mac
A lot of people use Cyberduck on Mac. It is a solid, well-known SSH client that is quite popular.
Together with our customers, our mission is to secure their digital business on on-premises, cloud, and hybrid ecosystems cost-efficiently, at scale, and without disruptions to their operations or business continuity.
Источник
Quick Introduction to SSH for Mac Admins
What is SSH?
SSH is short for ‘Secure SHell’. It is a protocol that allows you to open a shell (terminal session) on another remote computer over the network. On macOS you will usually initiate an SSH session with the Terminal application, though there are other third party applications for macOS and iOS that support the SSH protocol as well.
On macOS SSH access is sometimes called ‘Remote Login’.
As the name implies, connections over SSH are encrypted and secure. This may not seem unusual today, but it did replace many unsecured protocols such as telnet and rlogin .
SSH is supported on many platforms. You can use SSH to connect to Macs as well as any other computer which supports SSH and has it enabled. Of course, when you SSH to a different system, the environment you get through SSH might be very different (i.e. not bash , different commands, etc.), so be sure you understand the remote system.
Enable SSH access
By default SSH access is disabled on macOS. Before you can connect to a Mac with SSH you need to enable access. In the UI you can do this in System Preferences > Sharing, by enabling the ‘Remote Login’ option. Here you can also control whether all users on the Mac can get SSH access or just some of them.
The Sharing pane will also show the current hostname of this computer:
You can also enable SSH access from the command line with
and turn it off again with
Turning SSH off with this command helpfully reminds you that if you are currently connected remotely, you will disconnect with this command and have to login locally to re-enable. To override this helpful notice, you can add the -f option:
And if you want to know which hostname a Mac thinks it is, use the hostname command:
Note: If you want to control which users have access with a script, I have an example in this post. This post was written for Munki but should be fairly easy to adapt to other systems.
Connect with SSH
To connect to a machine from another Mac (the one you are working on) is simple enough. Open Terminal and enter:
or alternatively (different syntax, same result, which one you prefer is a matter of taste)
If you do not give a username , ssh will use the short name you are currently logged in as. That is a useful shortcut if the username is the same on both systems.
When you connect to a remote machine for the first time you will get this prompt:
(Your actual fingerprint will look differently.) This prompt tells you that your ssh does not recognize this host and gives you a chance to not connect. For now, type yes to confirm. This will add the host to the list of known hosts, so the prompt will not return when you connect again. We will discuss keys and security in a later post.
Next ssh will prompt you for the password on the remote computer. Once you enter that you will get the prompt and have a secure shell to the remote computer. Any command you enter now, will be run on the remote computer.
You can connect with ssh when no user is logged in, i.e. the Mac is sitting at the login window. You can even connect with one user, while a different user is logged into the Mac with a UI session. In these cases, commands that interact with the UI, will fail, since the UI is either not running, or running as a different user. Most common examples are open and osascript (AppleScript).
If you happen to be logged in on the same Mac with the same user, then the command will work, but open will open and display the Finder window on the remote Mac, not the Mac you are working on, which can be confusing.
Ending it
To end the remote session, just use the exit command.
This will return you to the shell on your Mac where you executed the ssh command.
SSH Shortcut Files
If you frequently connect to certain hosts you may want to create an ssh short cut file, which you can then just double click or invoke with spotlight.
Execute Just One Command
Instead of opening a remote shell you can use ssh to just execute just a single command on the remote host:
The ssh command will prompt for the password and the print the output of the command from the remote machine. This can be very useful. You can combine multiple commands with ;
In some case the command you want to execute remotely can prompt for information, usually a password. You can add the -t option to make ssh use an interactive shell:
This will prompt twice for the password. The first time to establish the remote connection and the second time for sudo on the remote machine.
Sending single commands with ssh can be useful for automating workflows in scripts. However, the requirement to keep entering passwords will be very detrimental to automation. It will also be annoying when you frequently connect to specific remote Macs.
Источник
Как включить ssh на mac из командной строки 2021
Mac SSH Verbindung — Terminal — Tutorial
Все современные Mac под управлением macOS или Mac OS X поставляются с предустановленным SSH по умолчанию, но демон SSH (Secure Shell) также отключен по умолчанию. Опытные пользователи Mac могут по достоинству оценить знание того, что возможность включить SSH и отключить SSH полностью доступны из командной строки Mac OS, что позволяет просто разрешить или запретить удаленные подключения к компьютеру. Для включения SSH из Терминала на любом Mac нет необходимости загружать, загружать или компилировать kext, вам просто нужно выполнить команду настройки системы, как мы покажем в этом руководстве.
Быстрое примечание стороны; Это руководство относится ко всем версиям MacOS и Mac OS X, но на самом деле предназначено для более опытных пользователей, которые проводят много времени в Терминале. Если вы хотите включать и выключать SSH и избегать командной строки, вы можете сделать это, включив Удаленный вход в систему на панели настроек «Общий доступ» на Mac, или остановить сервер, оставив его без контроля. Если вы не используете ssh на регулярной основе, нет причин включать сервер ssh на Mac.
Как проверить, включен ли удаленный вход SSH в Mac OS через терминал
Хотите проверить текущее состояние SSH на Mac? Используя командную строку systemsetup, мы можем быстро определить, включены ли в настоящее время SSH и удаленный вход на любом Mac:
sudo systemsetup -getremotelogin
Если удаленный вход в систему и SSH в настоящее время включены, команда и отчет сообщат: «Удаленный вход в систему: включен», тогда как если SSH отключен и находится в состоянии macOS по умолчанию, то будет указано «Удаленный вход в систему: выкл.
Включить SSH на Mac из командной строки с помощью systemsetup
Чтобы быстро включить SSH-сервер и разрешить входящие ssh-соединения с текущим Mac, используйте флаг -setremotelogin с systemsetup следующим образом:
sudo systemsetup -setremotelogin on
Команда sudo необходима, потому что команда systemsetup требует прав администратора, как и при включении удаленного входа в настройках «Общий доступ» на Mac для включения серверов защищенной оболочки.
Нет подтверждения или сообщения о том, что Удаленный вход в систему и SSH были включены, но вы можете использовать вышеупомянутый флаг -getmorelogin, чтобы проверить, что сервер SSH действительно сейчас работает. И да, использование -setremotelogin применяется для включения серверов ssh и sftp на Mac.
После включения ssh любая учетная запись пользователя или лицо, имеющее логин на текущем Mac, может получить к нему удаленный доступ с помощью команды ssh, направленной на IP-адрес Mac, например:
После подключения пользователь получит удаленный доступ к компьютеру через командную строку, а если у него есть учетная запись администратора или пароль администратора, он также получит полный доступ к удаленному администрированию.
Отключите SSH в Mac OS с помощью systemsetup
Если вы хотите отключить SSH-серверы из командной строки и тем самым предотвратить удаленные подключения, просто включите «выключен» с «-setremotelogin» флаг systemsetup следующим образом:
sudo systemsetup -setremotelogin off
Опять же, sudo необходимо для выключения SSH и отключения серверов ssh и sftp.
Когда вы успешно выполните команду, вас спросят: «Вы действительно хотите отключить удаленный вход? Если вы это сделаете, вы потеряете это соединение и сможете включить его только локально на сервере (да / нет)? », Поэтому для подтверждения введите« да », что отключит SSH, а также отключит все активные соединения SSH с Mac в вопрос. Если вы хотите избежать ввода да / нет, возможно, для включения в скрипт установки или иным образом, вы можете использовать флаг -f, чтобы обойти вопрос следующим образом:
sudo systemsetup -f -setremotelogin off
Точно так же вы также можете использовать -f, чтобы пропустить любые запросы относительно включения SSH.
systemsetup -f -setremotelogin on
Обратите внимание, что независимо от того, выключаете ли вы SSH или включаете SSH из командной строки, настройки панели системных настроек «Удаленный вход» в графическом интерфейсе Mac OS X также будут соответствующим образом отражены.
Источник
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.
Источник