Ssh with terminal mac os

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.

Читайте также:  Скриншоты с прокруткой windows

Источник

Как включить ssh на mac из командной строки 2021

Mac SSH Verbindung — Terminal — Tutorial

  • 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

    Читайте также:  Create windows boot disks

    Обратите внимание, что независимо от того, выключаете ли вы SSH или включаете SSH из командной строки, настройки панели системных настроек «Удаленный вход» в графическом интерфейсе Mac OS X также будут соответствующим образом отражены.

    Источник

    RTFM.WIKI

    Ordnung muß sein. Ordnung über alles (18+)

    Инструменты пользователя

    Инструменты сайта

    Боковая панель

    Линкшэринг

    socialite Display:icon facebook twitter

    ALARM!

    Добавить новую страницу

    Реклама

    Содержание

    SSH: подключение по ключу без пароля на примере macOS

    Минимум теории и максимум хауту. За теорией лучше обратиться на сайт wikipedia или на ssh.com

    Шаг 1. Создать пару ключей

    Нужно создать пару ключей: приватный (закрытый) ключ и публичный (открытый) ключ. Приватный ключ никогда никуда никому не передавать. Публичный ключ можно показывать всем.

    Пр желании можно дать ключу другое имя (ключ -f ), например id_rsa_server_vps13.

    Следующий пункт passphrase. Это парольная фраза или проще говоря пароль для ключа.

    Минусы. Его нужно будет вводить каждый раз, когда используется ключ.
    Очевидный плюс. Если файл окажется в чужих руках без парольной фразы использовать его не получится. Ну и не стоит использовать пароли admin111 или qwerty123.

    Шаг 2. Скопировать открытый ключ на удаленный хост

    Как всегда в unix есть множество вариантов для этого.

    Долгий путь

    В macOS можно скопировать содержимое файла в буфер обмена с помощью pbcopy

    Подключаемся к удаленному серверу, переходим в директорию .ssh и открываем (или создаем) файл authorized_keys.

    Добавляем ключ из буфера обмена.

    Кстати каждый ключ должен быть на отдельной строке. И никаких пустых строк между ключами.

    ssh-copy-id

    Начиная с Sierra утилита уже есть в составе системы и не нужно ставить с github или через homebrew.

    или с указанием имени ключа

    cat + ssh

    Шаг 3. Локальный конфиг SSH и тест подключение

    Добавим локальный файл конфигурации для SSH клиента в файл

    Особый интерес представляют опции UseKeychain и AddKeysToAgent.

    Пароль приватного ключа можно хранить в «Связке ключей» (Apple KeyChain). Один раз добавили и всё — больше никогда не надо вводить никаких паролей для подключения по ssh.

    В каком-то релизе (Sierra? у меня не Linux, чтобы отслеживать это) всё сломали и Terminal теперь по-умолчанию не использует keychain.

    Опция AddKeysToAgent вышла в OpenSSH 7.2 еще в 2016 году, но я узнал про нее только сейчас.

    В клиент ssh добавлена опция AddKeysToAgent, управляющая передачей в ssh-agent закрытого ключа, используемого в процессе аутентификации. Опция может принимать значения ‘yes’, ‘no’, ‘ask’, и ‘confirm’ (по умолчанию ‘no’)

    Что еще важного в ссылках выше?

    Буду рад если кто-то более подробно разобрался в данном вопросе и дополнит заметку.

    Источник

    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.*

    Читайте также:  Astra linux это debian или ubuntu

    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.

    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!

    Источник

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