Windows how to connect to ssh

Windows how to connect to ssh

Connecting Windows via SSH Using Built-in OpenSSH Server

Windows 10 1809 and Windows Server 2019 have got a built-in SSH server based on OpenSSH. In this article we’ll show how to install and configure an OpenSSH server on Windows 10 and connect to it remotely over protected SSH protocol (just like in Linux 🙂 ).

How to Install OpenSSH Server on Windows?

Let’s see on how to install OpenSSH Server feature on Windows 10 1903 (in Windows Server 2019 the procedure is the same).

The OpenSSH package (like RSAT) is added to these (and newer) Windows versions as the Feature on Demand (FoD).

If you have a direct Internet access, you can install OpenSSH using PowerShell:

dism /Online /Add-Capability /CapabilityName:OpenSSH.Server

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Configure SSH Server on Windows 10/Windows Server 2019

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

By default, important OpenSSH components are located in these folders:

After OpenSSH installation, a new local user (sshd) is created on the computer.

OpenSSH Server Configuration File (sshd_config)

You can change your OpenSSH server settings in the config file: %programdata%\ssh\sshd_config.

For example, to deny SSH connection for the specific domain user account (or all domain users), add these directives to the end of the file:

To allow SSH connection to the specific domain group only:

Or you can allow access to a local group:

You can deny access to the accounts with the administrator privileges. In this case, if you need to perform any privileged actions in your SSH session, you will have to use runas.

The following directives allow SSH access using RSA keys and passwords (we’ll look on how to use RSA keys to access Windows through SSH in the next article in detail):

You can change the port OpenSSH receives connections to in the Port directive of the sshd_config file.

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

How to Connect to Windows 10 via SSH?

Now you can try to connect to your Windows 10 through the SSH client (I am using PuTTY, but you can use a built-in Windows SSH client instead).

At the first connection, a standard request to add the host to the list of known SSH hosts will appear.

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Click Yes, and logon to your Windows 10 under Windows user.

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

If the SSH connection is successful, the cmd.exe shell will start with a prompt string.

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

You can run different commands, scripts or apps in the command prompt.

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

I prefer working in the PowerShell console. To start it, run this command:

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

In order to change the default cmd.exe shell to PowerShell for OpenSSH, make changes to the registry using the following PowerShell command:

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Restart your SSH connection and make sure that PowerShell is now used as a default SSH shell (this is shown by PS C:\Users\admin> ).

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

The PowerShell console has been started in your SSH session, and familiar features work in it: tab autocompletion, PSReadLine color highlighting, command history, etc. If the current user is a member of the local administrators group, all session commands are executed elevated even if UAC is enabled.

Использование встроенного SSH клиента в Windows 10

В Windows 10 и Windows Server 2019 появился встроенный SSH клиент, который вы можете использовать для подключения к *Nix серверам, ESXi хостам и другим устройствам по защищенному протоколу, вместо Putty, MTPuTTY или других сторонних SSH клиентов. Встроенный SSH клиент Windows основан на порте OpenSSH и предустановлен в ОС, начиная с Windows 10 1809.

Установка клиента OpenSSH в Windows 10

Клиент OpenSSH входит в состав Features on Demand Windows 10 (как и RSAT). Клиент SSH установлен по умолчанию в Windows Server 2019 и Windows 10 1809 и более новых билдах.

Проверьте, что SSH клиент установлен:

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

В нашем примере клиент OpenSSH установлен (статус: State: Installed).

Если SSH клиент отсутствует (State: Not Present), его можно установить:

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

]Бинарные файлы OpenSSH находятся в каталоге c:\windows\system32\OpenSSH\.

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Как использовать SSH клиенте в Windows 10?

ssh
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char]
[-F configfile] [-I pkcs11] [-i identity_file]
[-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
[-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
destination [command]

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Для подключения к удаленному серверу по SSH используется команда:

Если SSH сервер запущен на нестандартном порту, отличном от TCP/22, можно указать номер порта:

Например, чтобы подключиться к Linux хосту с IP адресом 192.168.1.202 под root, выполните:

Затем появится запрос пароля указанной учетной записи, укажите пароль root, после чего должна открытся консоль удаленного Linux сервера (в моем примере на удаленном сервере установлен CentOS 8).

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Если вы используете SSH аутентификацию по RSA ключам (см. пример с настройкой SSH аутентификации по ключам в Windows), вы можете указать путь к файлу с закрытым ключом в клиенте SSH так:

Также вы можете добавить ваш закрытый ключ в SSH-Agent. Сначала нужно включить службу ssh-agent и настроить ее автозапуск:

set-service ssh-agent StartupType ‘Automatic’
Start-Service ssh-agent

Добавим ваш закрытый ключ в базу ssh-agent:

Теперь вы можете подключиться к серверу по SSH без указания пути к RSA ключу, он будет использоваться автоматически. Пароль для подключения не запрашивается (если только вы не защитили ваш RSA ключ отдельным паролем):

Еще несколько полезных аргументов SSH:

SCP: копирование файлов из/в Windows через SSH

С помощью утилиты scp.exe, которая входит в состав пакета клиента SSH, вы можете скопировать файл с вашего компьютера на SSH сервер:

scp.exe «E:\ISO\CentOS-8.1.1911-x86_64.iso» root@192.168.1.202:/home
Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Можно рекурсивно скопировать все содержимое каталога:

И наоборот, вы можете скопировать файл с удаленного сервера на ваш компьютер:

scp.exe root@192.168.1.202:/home/CentOS-8.1.1911-x86_64.iso e:\tmp

Итак, теперь вы можете прямо из Windows 10 подключаться к SSH серверам, копировать файлы с помощью scp без установки сторонних приложений и утилит.

Подключение с помощью SSH

OpenSSH можно использовать для подключения к тестовых устройствам и виртуальным машинам фабрики ОС, а также выполнения команд или передачи файлов. OpenSSH (Secure Shell) — это стандартный протокол для безопасных подключений к терминалу.

Вы можете использовать SSH для подключения ко всем образам ОС фабрики

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Что необходимо для подключения с помощью SSH

Чтобы подключиться к устройству с помощью SSH, вам потребуется:

Запуск сервера SSH

На изображениях, включающих манифест компонента WindowsCoreNonProductionFM, можно добавить WCOS_OPENSSH_AUTOSTART эту функцию для автоматического запуска сервера SSH.

Если образ не настроен для автоматического запуска SSH-сервера, можно использовать портал устройств Windows для запуска сервера SSH вручную.

Подключение с помощью имени и пароля

Чтобы подключиться с помощью имени пользователя и пароля, необходимо сначала настроить имя пользователя и пароль. Настройка имени пользователя и пароля SSH зависит от используемого продукта фабрики ОС.

Имя пользователя и пароль в заводской ОС

Фабрика ОС включает встроенную учетную запись администратора, которую можно использовать для подключения к SSH:

Подключение с помощью пары ключей

Если у вас есть пара ключей для SSH (дополнительные сведения см. в документации клиента SSH), ее можно использовать вместо имени пользователя и пароля.

Вам потребуется открытый ключ в формате OpenSSH. Запустите ssh-keygen.exe на компьютере технического специалиста, чтобы создать его. ssh-keygen входит в состав Windows.

Создание keypair

В командной строке на компьютере технического специалиста запустите, ssh-keygen.exe чтобы создать открытый и закрытый ключи. При выполнении этой команды можно сохранить ключи в расположении на компьютере, а также задать пароль:

Эта команда запросит следующие сведения и предоставит выходные данные, аналогичные приведенным ниже.

Перейдите в папку, в которой хранятся ключи, вы увидите закрытый ключ без расширения и открытый ключ с расширением PUB.

Откройте файл открытого ключа с помощью текстового редактора. Открытый ключ не учитывается. Вот как они выглядят:

Скопируйте содержимое открытого ключа в буфер обмена.

Подключение на устройство WCOS с помощью портала устройств. Naveigate на вкладку SSH в левой области и скопируйте открытый ключ из буфера обмена в поле с заголовком «Открытый ключ » для нужного пользователя.

Подключение

После настройки аутентификации вы можете подключиться к устройству фабрики ОС:

Откройте окно командной строки на компьютере технического специалиста.

Подключение на устройство:

Где user указано имя пользователя, выбранное при настройке SSH, а 192.168.1.2 — IP-адрес устройства производственной ОС.

Где C:\Users\User/.ssh/id_rsa идентификатор закрытого ключа, — это имя пользователя, user выбранное при настройке SSH, а 192.168.1.2 — IP-адрес устройства с заводской ОС.

Введите пароль для пользователя, если вы подключаетесь к имени пользователя и паролю, или если вы настроили ключ, чтобы требовать пароль.

Безопасный FTP

SSH можно использовать для передачи файлов по протоколу sftp. Если вы включили SSH на устройстве с заводской ОС, вы также сможете подключиться к sftp.

Если вы предпочитаете программу командной строки, можно использовать sftp и scp :

Приведенные выше служебные программы включены в Windows и могут быть запущены путем запуска командной строки.

Connect using SSH

You can use OpenSSH to connect to your Factory OS test devices and VMs and run commands or transfer files. OpenSSH (Secure Shell) is a standard protocol for secure terminal connections.

You can use SSH to connect to all Factory OS images

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

What you need to connect using SSH

To connect to a device using SSH, you’ll have need:

Start the SSH server

On images that include the WindowsCoreNonProductionFM feature manifest, you can add the WCOS_OPENSSH_AUTOSTART feature to automatically start the SSH server.

If your image isn’t configured to automatically start the SSH server, you can use Windows Device Portal to manually start the SSH server.

Connecting using a name and password

To be able to connect using a username and password, you have to first configure a username and password. Configuring an SSH username and password depends on the Factory OS product that you’re using.

Username and password in Factory OS

Factory OS includes a built-in administrator account that you can use to connect with SSH:

You can customize the username and password with the SSHUsername and SSHPassword settings in the settings customization framework.

Connecting using a key pair

If you have a key pair for SSH (see your SSH client documentation for details), you can use it instead of a username and password.

You’ll need a public key in OpenSSH format. Run ssh-keygen.exe on your technician PC to generate one. ssh-keygen is included with Windows.

Create a keypair

From a Command prompt on your technician PC, run ssh-keygen.exe to generate a public and private keypair. When you run this command, you can choose to save the keys to a location on your PC, and also set a password:

This command will prompt you for the following information, and provide output similar to the following:

Open the public key file with a text editor. The public key isn’t sensitive. Here’s what they look like:

Copy the contents of your public key to the clipboard.

Connect to your WCOS device with Device Portal. Naveigate to the SSH tab in the left-pane, and copy the public key from your clipboard into the box titled Public Key for your desired user.

Connect

Once you have authenication configured, you can connect to your Factory OS device:

Open a Command prompt window on your technician PC.

Connect to the device:

Where user is the username you chose when setting up SSH, and 192.168.1.2 is your Factory OS device’s IP address.

Where C:\Users\User/.ssh/id_rsa id your private key, user is the username you chose when setting up SSH, and 192.168.1.2 is your Factory OS device’s IP address.

Enter the password for your user if you’re connecting with a username and password, or if you configured your key to require a password.

Secure FTP

You can use SSH for file transfer, over the sftp protocol. If you’ve enabled SSH on your Factory OS device, you’ll also be able to connect with sftp.

WinSCP is the most popular GUI Client for file transfer over sftp in Windows. Follow the documentation to learn how to use it.

If you prefer a command-line tool, you can use sftp and scp :

The above utilities are included in Windows and can be run by launching a Command prompt.

How to use SSH (Secure Shell) on Windows and Mac to access your account

This article describes how to connect to your A2 Hosting account securely using SSH.

What is SSH access and why would you need to use SSH?

Secure Shell (SSH) is a protocol that provides secure command-line access to your A2 Hosting account. By using SSH, you can remotely log in to your A2 Hosting account and run commands as if you were sitting right at the server.

With its simplified interface, the command line allows you to perform tasks with text commands. You’ll also find that SSH is a time-saving solution that can ultimately help speed up many tasks. For example, you can do tasks that you cannot do with your account’s hosting control panel.

How SSH works

An SSH connection creates a secure connection between two computers. SSH is able to provide a safe, encrypted connection between the client and the server through this encrypted tunnel. From here, you can easily transfer files between the connected machines, or run programs and commands that would otherwise require more complicated screen-sharing solutions. It is as if you were right in front of your server, in the data center where it is located.

What you need to create an SSH connection

Just as you need an FTP client to manage files with FTP, you need an SSH client on your computer to make an SSH connection. PuTTY and WinSCP are two popular SSH solutions for Windows users. Both Linux and macOS have built-in terminals, so it is not necessary to download an SSH client. Our step-by-step SSH account access instructions, outlined below, will help you access your account remotely.

Where can you find SSH connection details?

To find the SSH connection details for your account, log in to the A2 Hosting Customer Portal at https://my.a2hosting.com.

Click on your plan, located in the Your Active Products/Services section:

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

Click anywhere on your package. This takes you to the Manage page. The Manage page contains all of the technical information you need for SSH, such as your IP Address, SSH Port, Username, and Password:

Windows how to connect to ssh. Смотреть фото Windows how to connect to ssh. Смотреть картинку Windows how to connect to ssh. Картинка про Windows how to connect to ssh. Фото Windows how to connect to ssh

For more information about how to use the Customer Portal, please see these articles.

How to use an SSH client

Once you have the connection details for your account, you are ready to use an SSH client to connect to the server. Follow the appropriate procedure below for your computer’s operating system.

Windows operating systems

You can use any SSH client, but we will show how to use PuTTY, which you can download here. To connect to your account using PuTTY, follow these steps:

macOS and Linux operating systems

Both macOS and Linux include SSH clients, so connecting to your A2 Hosting account on these operating systems is easy. You do not have to download a special client.

To connect to your account, follow these steps:

At the command prompt, type the following command. Replace username with your A2 Hosting username, and example.com with your site’s domain name:

Type your password when you are prompted to do so.

When the remote server’s command line prompt appears, you are connected. The initial command line prompt is:

To close the SSH connection when you are done, type exit and then press Enter.

In the command in step 2, we explicitly specify the port number, the username, and the hostname. However, you can also define these settings for a remote host in your

/.ssh/config file as follows:

The Host value can be any name you want; it is simply a label for the other settings. The Hostname value is the remote host you want to access, the port number is 7822, and the User value specifies your A2 Hosting account username. With this configuration defined, you can connect to the account by simply using the Host value. You do not have to type the port number, username, and hostname each time. The following command demonstrates how to do this:

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *