- Connecting to a Remote Server Over SSH on a Mac
- Before You Begin
- Open the Terminal
- Connecting to the Remote Server Over SSH
- Ending the SSH Session
- Sending Commands Over SSH
- Sending a Single Command
- Sending Multiple Commands
- Using sudo
- Going Further
- Troubleshooting SSH Connection Issues
- Increasing Security
- How to connect to linux server from mac
- Connecting to amazon aws linux server by ssh on mac
- Trying to open a GUI from a remote server using Mac but not successfully
- How do I access my remote Ubuntu server via X-windows from my Mac?
- Connecting to MS SQL Server from R on Mac/Linux
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.
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
- 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.
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.
This page was originally published on Friday, June 25, 2021.
How to connect to linux server from mac
In order to forward remote apps to local X environment, you need to install X11 on your Mac (you can find it at apple support site): http://support.apple.com/kb/DL1605?viewlocale=en_US&locale=en_US From the X11 app, open the terminal, and then access the remote host with: Then, when logged, simply run the command for the desired app, ex: firefox, nautilus, thunderbird, whatever. You can even launch only the system (Ubuntu, Xubuntu, Mint, etc..) Once that’s installed, reboot and open an XQuartz terminal window and SSH to your Ubuntu Server system: If lightdm is running (see https://askubuntu.com/a/153423/66799 to read how turn it on and off as needed), run this command to get Ubuntu Unity tunnelled to your Mac over X11: This works for me with Ubuntu Server 12.04 LTS and Mac OS X Mountain Lion 10.8.2, but I do get occasional Composiz errors.
Connecting to amazon aws linux server by ssh on mac
You’ll want to put the keypair in /.ssh . If that folder doesn’t exist, create it. Once you put the keypair in there you have to change the permissions on the file so only your user can read it. Launch the terminal and type
That limits access to the file, and then to limit access to the folder type
You have to limit the access because the OpenSSH protocol won’t let you use a key that other’s can view.
Then to log into your instance, from the terminal you would enter
you can also create a file ~/.ssh/config chmod it 644 then inside you can add something like this
host mybox-root Hostname [the IP or dns name] User root IdentityFile ~/.ssh/[your keypair here]
You can use Java MindTerm to connect to your EC2 server in Macbook pro. It works for me. here are the more details and step by step instruction.
Macos — How to connect SQL Server on mac, When you trying to connect SQL server with Windows Authentication via mac, data studio tries to use your mac log in properties and it cannot be the same as the windows server you want to connect to. If you want to log in SQL server via mac with data studio, you need to know a SQL server user and its …
Trying to open a GUI from a remote server using Mac but not successfully
Try the following on your Mac OSX system:
Enable X11 Forwarding with the “X11Forwarding yes” option set in /private/etc/sshd_config for your SSH daemon’s own local X11 host. This will allow the Mac OSX host to receive X11 client requests back from the remote machines (Linux) through ‘ssh‘ with the -X option set.
Then restart sshd on the Mac OSX host:
Under System Preference / Sharing pane on Mac OS X. The SSH daemon should be running on the remote machine as well!
How to Format a USB Drive on Linux That Works With, Type a name for your USB drive, select the “Other” radio button, then click the “Next” button. Select the “exFAT” radio button, then click the “Next” button. You’re warned that the USB drive will be wiped clean, and you’re shown the details of the drive so that you can confirm it is the drive you intend to format.
How do I access my remote Ubuntu server via X-windows from my Mac?
There are several methods to accomplished that, depending of what you really need to do.
In order to forward remote apps to local X environment, you need to install X11 on your Mac (you can find it at apple support site): http://support.apple.com/kb/DL1605?viewlocale=en_US&locale=en_US
From the X11 app, open the terminal, and then access the remote host with:
Then, when logged, simply run the command for the desired app, ex: firefox, nautilus, thunderbird, whatever.
You can even launch only the system (Ubuntu, Xubuntu, Mint, etc..) Main Menu, and interact with the remote system from there, without the need of a full graphical front-end. On a remote Linux Mint env, i simply run:
If you really need it, you can even start the remote graphical environment locally at your Mac’s X11, simply running:
ubuntu-session xubuntu-session etc. (depends of your remote environment)
Better than any VNC, even better than an X11VNC connection! Secured and compressed connection FTW.
On your Mac, you’ll need to install XQuartz, if you haven’t done so already (see http://xquartz.macosforge.org). Once that’s installed, reboot and open an XQuartz terminal window and SSH to your Ubuntu Server system:
If lightdm is running (see https://askubuntu.com/a/153423/66799 to read how turn it on and off as needed), run this command to get Ubuntu Unity tunnelled to your Mac over X11:
gnome-session --session=ubuntu-2d
This works for me with Ubuntu Server 12.04 LTS and Mac OS X Mountain Lion 10.8.2, but I do get occasional Composiz errors. That said, I always got Composiz errors when running Ubuntu Desktop locally, too. (-:
You can log out of Unity to close the Ubuntu Desktop windows.
You have the right idea but the wrong syntax 🙂
startx will not start over an ssh like that because it needs a screen (aka X server to talk to)
try this command to start the desktop gui
this will start the desktop environment.
ssh -X nautilus username@host
note did not test above line
If everything works fine you should see the ubuntu file manager popup. If not you may be missing some librarys or the syntax of the command is wrong (of the top of my head didn’t try it).
How do I connect to this localhost from another computer, In the terminal, on MAC and LINUX type ifconfig |grep inet, on WINDOWS type ipconfig. Let’s assume the IP address of this computer is 192.168.1.5. 3b Edit the hosts file on the computer you are …
Connecting to MS SQL Server from R on Mac/Linux
I’ve been struggling for a while on this. Here’s what I found.
- Download from here — Microsoft JDBC driver for SQL server
- Unzip the file, where you will find sqljdbc4.jar .
- Use:
If i’m right, the idea is that for the PATH variable in drv function, one will need to specify the PATH where the JDBC driver is located (so if none, then downloaded it FIRST). Otherwise, one shall receive the common class not find error.
The following code achieves your goal of connecting to R from Mac OS x. Download the Microsoft JDBC driver from Microsoft here
Link to Gist / Code in Github
# install.packages("RJDBC",dep=TRUE) library(RJDBC) drv
I had this problem with jtds-1.3.1 on Linux. The problem disappeared when I tried switching to jtds-1.2.7. It appears there is something in jtds-1.3.* which makes it incompatible with RJDBC.
Install SQL Server command-line tools on Linux, For an example of how to use sqlcmd to connect to SQL Server and create a database, see one of the following quickstarts: Install on Red Hat Enterprise Linux; Install on SUSE Linux Enterprise Server; Install on Ubuntu; Run on Docker; For an example of how to use bcp to bulk import and export data, …