Linux server mac client

Connecting to a Remote Server Over SSH on a Mac

Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.

A secure shell (SSH) is used for secure communication between devices. When most people refer to SSH, it is within the context of connecting from a local computer to a remote server, commonly for administration tasks related to website hosting.

This article covers the basics of connecting to a remote server (such as a Linode) over SSH on macOS.

Before You Begin

Ensure you have a Linux server with an SSH server (like OpenSSH) installed. Most Linux distributions have an SSH server preinstalled. If you wish to deploy a new server, follow the Creating a Compute Instance guide to create a Linode.

Open the Terminal

On your local computer, open the terminal application you wish to use. The terminal allows you to access your operating system’s shell environment and run programs through the command line.

The default terminal emulator for macOS is called Terminal. To open this program, access Spotlight by pressing Cmd + Space on the keyboard and type “Terminal” in the search box. In the search results, click on Terminal.app. Refer to Apple’s Open or Quit Terminal on Mac guide for additional methods of opening Terminal.

Using Spotlight to open the Terminal app

As alternatives to the Terminal app, other popular and highly customizable macOS compatible terminal applications include iTerm2 and Hyper.

Connecting to the Remote Server Over SSH

  1. Within the terminal, enter the following command, replacing [username] with the username of the remote user and [ip-address] with the IP address or domain name of the remote server.

If the server’s SSH port is something other than 22, it needs to be specified in the SSH command. To do this, use the -p option as shown in the command below. Replace [port-number] with the port number that the remote SSH server is using.

The authenticity of host ‘example.com (93.184.216.34)’ can't be established. ECDSA key fingerprint is SHA256:d029f87e3d80f8fd9b1be67c7426b4cc1ff47b4a9d0a84. Are you sure you want to continue connecting (yes/no)?

You can verify the fingerprint by following the instructions on the Verifying the Authenticity of a Remote Server guide.

If you recently rebuilt your server, you might receive an error message when you try to connect. This happens when the remote host key changes. To fix this, revoke the key for that IP address.

Warning: Permanently added 'example' (ECDSA) to the list of known hosts.

Once you have successfully connected, your terminal should be using the remote shell environment for the server. Your command prompt should now show the username and hostname configured for the server. You can now run any commands that you have available on that server. This includes many of the basic Linux commands, such as ls , cd , rm , and those covered in Using the Terminal guide. Getting to know these commands will help you navigate around your server.

Читайте также:  Linux get install date

Ending the SSH Session

After you are done, log out of the session by typing exit . The terminal then shows something similar to:

logout Connection to 93.184.216.34 closed.

At this point, the shell prompt returns to the one for the local workstation and the terminal application can be closed if it’s no longer needed.

Sending Commands Over SSH

Instead of using SSH to open your remote server’s console, you can run commands on your server without leaving your local shell environment. This can enable you to quickly run commands both locally and remotely in the same terminal window.

Sending a Single Command

To run a single command on your remote server, use the following command. Replace [username] with the username of the remote user, [ip-address] with the IP address or domain name of the remote server, and [command] with the command you wish to run.

As an example, running ssh me@192.0.2.0 ls lists all the files in the home directory of the user called me . This can be useful to find the uptime of the server ( ssh me@192.0.2.0 uptime ) or maybe determine its Linux distribution and version ( ssh me@192.0.2.0 lsb_release -a ).

Sending Multiple Commands

To run multiple commands on your remote server (one after the other), use the following command. Replace [command-1], [command-2], and [command-3] with the commands you wish to run.

The commands should be separated by a semi-colon ( ; ) and all of the commands together should be surrounded by double quotation marks ( » ). For example, if you wanted to create a file named bar.txt in a directory called foo within the user me’s home directory, run: ssh me@192.0.2.0 «mkdir foo; cd foo; touch bar.txt .

Using sudo

It’s recommended to disable root access over SSH and only log in to your remote server through a limited user account. However, some commands require elevated privileges, which can usually be accomplished by prepending the command with sudo . If you attempt to do this while running commands directly through the SSH command, you may receive an error such as “no tty present” or there isn’t a “stable CLI interface”. To run the sudo command in these instances, use the -t option, which forces a psuedo-terminal allocation. For example, to update your packages on a Debian-based system, run ssh linode@example.com -t «sudo apt update» .

Going Further

Troubleshooting SSH Connection Issues

If SSH isn’t connecting you to your Linode, you may need to investigate the state of your server. See the guide Troubleshooting SSH for assistance.

Increasing Security

  • Now that you can connect from your Linux machine to the Linode over SSH, save not only time but also make the connection even more secure by using SSH public key authentication. For more information, see SSH add keys.
  • See the “Harden SSH Access” section of Setting Up and Securing a Compute Instance guide to review how to secure SSH on the server’s side, and the Advanced SSH Server Security for more information on making it even more secure.
Читайте также:  Linux bluetooth mouse lag

This page was originally published on Friday, June 25, 2021.

Источник

Copy files from Linux server to Mac desktop

I have a folder on a Linux server and I have to transfer that file from there to my Mac desktop. I have never done it. What is the best way to do that? I am trying to use terminal but is there any tool like WinSCP to do that?

In addition to the answers below, consider installing mc (aka Midnight Commander) to run on top of ssh. It behaves like nc on windows.

5 Answers 5

scp filename.txt user@remote_server:/Users/YOURNAME/ 
scp user@remote_server:/Users/YOURNAME/filename.txt . 

The general syntax of the scp command is the following.

    To copy a file from the local server to the remote one:

scp FILENAME user@remote_server:/remote/path/FILENAME 
scp user@remote_server:/remote/path/FILENAME /local/path/FILENAME 

If sshd is not running in Mac, Connection refused error will occur. So enable Remote Login in Preferences -> Sharing and then do this.

In case someone gets port 22: Operation timed out, their server probably has a different port and it should be specified. scp -P 6418 user@remote_server:/Users/YOURNAME/filename.txt .

In my case to transfer from Linux Mint 20.2 to mojave. In my linux terminal instead of this scp filename.txt user@remote_server:/Users/YOURNAME/ I only specify the folder at the end e.g.: scp filename.txt user@remote_server:Downloads

You can use SSH File Transfer Protocol, sftp from your Mac terminal.

Enter the user@remote_server’s password:

2. get /remote/path/FILENAME /local/path/FILENAME 

Just in case you are not certain about the file name, you can change to the source directory and list the segments in your source directory

3. cd /remote/path 4. ls 5. get FILENAME_2 /local/path/FILENAME_2 

WinSCP is a SFTP/SCP/FTP client for Windows.

Similar clients exist for the Mac — good examples are Transmit and Cyberduck.

Transmit and Cyberduck understand FTP, SFTP and WebDAV but it entirely depends how the linux server is set up whether you can access that particular folder with one of those services.

If it’s going to be a regular exercise, then have a look at installing OS X FUSE / MacFUSE, see:

Perhaps the easiest and most flexible way to transfer files to your Mac desktop from Linux is using Midnight Commander. To do so network the two machines, install mc on the Linux box, enable Remote Login on the Mac and use Shell login to connect to your Mac in Midnight Commander.

A sample connection string for shell logins looks like:

Use that in Midnight Commander if your Mac has a hostname mbp and is on the local network. For instructions with screenshots visit Copy Files from Linux to macOS Desktop.

Источник

Доступ через MAC с Ubuntu 18.04 Server

В утилите winbox есть такая возможность к настраиваемому оборудованию фирмы Mikrotik подключаться, как через IP&MAC , вот второй способ интересен. Я порой сталкивался, что есть какие-то скрипты позволяющие с системы Ubuntu 18.04 Server подключаться через mac соединение с устройством . Меня это заинтересовало и я начал копать. Пакет mactelnet-client использует разработку Mikrotik (MAC-Telnet protocol) на которой работает подключение через MAC адрес.

Читайте также:  Linux boot from gpt disk

ekzorchik@srv-bionic:~$ apt-cache search mactelnet

mactelnet-client — Console tools for telneting and pinging via MAC addresses

mactelnet-server — Telnet daemon for accepting connections via MAC addresses

ekzorchik@srv-bionic:~$ apt-cache show mactelnet-client | grep Version

ekzorchik@srv-bionic:~$ sudo apt-get install mactelnet-client -y

ekzorchik@srv-bionic:~$ whereis mactelnet

mactelnet: /usr/bin/mactelnet /usr/share/man/man1/mactelnet.1.gz

За справкой следует обращаться:

ekzorchik@srv-bionic:~$ mac mactelnet

ekzorchik@srv-bionic:~$ zcat /usr/share/man/man1/mactelnet.1.gz

Чтобы просканировать текущую сеть на наличии устройств к которым можно подключиться через MAC— адрес:

ekzorchik@srv-bionic:~$ mactelnet -l

Searching for MikroTik routers. Abort with CTRL+C.

IP MAC-Address Identity (platform version hardware) uptime

192.168.88.108 64:d1:54:5:bc:ce MikroTik (MikroTik 6.42.6 (stable) RB951Ui-2HnD) up 22 days 7 hours K2RF-4I3T bridge1

192.168.88.254 64:d1:54:66:55:ce slk/office (MikroTik 6.42.6 (stable) RB952Ui-5ac2nD) up 21 days 5 hours 5IC2-8QK6 bridge1

^C → по сочетанию клавиш «Ctrl + C» прерываем выполнение утилиты.

Итак утилита обнаружила, два микротика в локальной сети которые поддерживают подключение через mac-адрес, по сути это как-бы использование утилиты winbox. Ну по крайней мере я пока так себе это вижу.

Попробую подключиться из консоли к одному из Mikrotik:

ekzorchik@srv-bionic:~$ mactelnet 64:d1:54:66:55:ce

Connecting to 64:d1:54:66:55:ce. Connection failed.

Почему не подключилось — не могу знать, может в этот момент устройство было в перезагрузке в связи с обновлением к пример.

В составе установленного пакета mactelnet-client присутствует еще одна утилита именуемая, как macping :

ekzorchik@srv-bionic:~$ sudo macping 64:d1:54:66:55:ce

64:d1:54:66:55:ce 56 byte, ping time 4.15 ms
64:d1:54:66:55:ce 56 byte, ping time 1.78 ms
^C
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 1.78/2.96/4.15 ms

Проверка роутера на доступность через L2— уровень посредством использования утилиты macping:

ekzorchik@srv-bionic:~$ macping 64:d1:54:66:55:ce -c 2

You need to have root privileges to use macping.

Ага, для запуска нужно использовать повышение привилегий через sudo.

Ниже пример проверки доступности устройства и если нет ответа то уведомление о тот что нет ответа.

ekzorchik@srv-bionic:~$ sudo macping 64:d1:54:66:55:ce -c 2 >/dev/null 2>&1 || ( echo «No answer for 2 pings»)

вывода нет значит команда отработала успешно, но если добавить еще команду которая будет при настроенном почтовом клиенте на системе (к примеру ssmtp) уведомлять заинтересованных людей о проблеме с хостом:

ekzorchik@srv-bionic:~$ sudo macping 64:d1:54:66:55:ce -c 2 >/dev/null 2>&1 || ( echo «No answer for 2 pings» | mail -s «router down» support@ekzorchik.ru )

Пока на этом всё, с уважением автор блога Олло Александр aka ekzorchik.

От ekzorchik

Всем хорошего дня, меня зовут Александр. Я под ником — ekzorchik, являюсь автором всех написанных, разобранных заметок. Большинство вещей с которыми мне приходиться разбираться, как на работе, так и дома выложены на моем блоге в виде пошаговых инструкции. По сути блог — это шпаргалка онлайн. Каждая новая работа где мне случалось работать вносила новые знания и нюансы работы и соответственно я расписываю как сделать/решить ту или иную задачу. Это очень помогает. Когда сам разбираешь задачу, стараешься ее приподнести в виде структурированной заметки чтобы было все наглядно и просто, то процесс усвоения идет в гору.

Источник

Оцените статью
Adblock
detector