Cách sử dụng SSH để kết nối an toàn trên macOS

[ad_1]

Cách sử dụng SSH để kết nối an toàn trên macOS


SSH (Secure Shell) cho phép bạn gửi các thông tin mật mã giữa các máy tính một cách an toàn và được mã hóa mà gần như không thể bị giải mã. Dưới đây là cách sử dụng nó trên macOS. Trước khi có các máy tính cá nhân, mọi người sử dụng các thiết bị gọi là terminal time-sharing trong các phòng máy tính kết nối với máy tính chính. Mỗi người dùng ngồi trước máy terminal chỉ là một màn hình và bàn phím kết nối với máy tính chính. Sau đó, khi máy tính mini bắt đầu xuất hiện, các terminal được kết nối qua mạng. Ban đầu, để truy cập vào máy tính khác trong mạng từ xa, họ sử dụng chương trình gọi là Telnet. Telnet là một trong những ứng dụng sớm nhất của internet, và được sử dụng phổ biến trong các cài đặt đại học và nghiên cứu. An ninh không được coi là vấn đề lúc ấy, vì phần lớn người dùng vẫn chưa sử dụng internet, và gian lận trực tuyến trên quy mô lớn chưa phải là vấn đề lớn. Sự thương mại hóa internet trong những năm 1990 đã thay đổi tất cả mọi thứ. Điều đó làm cho việc trao đổi dữ liệu cá nhân hoặc tài chính trở nên phổ biến. Telnet vẫn hoạt động, nhưng có một nhược điểm lớn trong thời đại của internet-mọi nơi: nó gửi và nhận toàn bộ dữ liệu dưới dạng văn bản thường. Điều này bao gồm thông tin cá nhân và tài chính, và trọng điểm nhất, mật khẩu – ai đó nghe trộm thông tin mạng có thể lấy cắp chúng. Để giải quyết vấn đề này, vào năm 1999, nhà phát triển người Phần Lan Tatu Ylonen tạo ra Secure Shell (SSH) – cả một giao thức mạng và công cụ UNIX để gửi và nhận dữ liệu qua mạng không an toàn thông qua mã hóa kết hợp với Cơ sở hạ tầng Khóa công khai (PKI). Cơ sở Hạ tầng Khóa công khai Một trong những vấn đề khó khăn nhất để giải quyết trong an ninh máy tính là làm cách nào để đảm bảo tính xác thực của một người dùng từ xa. Có một số kỹ thuật mà hacker có thể sử dụng để mạo danh người dùng, và đó là khó khăn cho máy chủ và người dùng khác nhằm đảm bảo kẻ mạo danh không có quyền truy cập trái phép. Ngay cả những mật khẩu dài, khó đoán cũng có thể bị đánh crack bởi mạy siêu tính toán mạnh. Ngay cả những mật khẩu tốt nhất cũng không an toàn. Và nguy hiểm nhất, mật khẩu có thể bị đánh cắp. Điều cần thiết là một giải pháp an toàn hơn, có thể được xác minh ở cả hai đầu của một kết nối bởi cả hai bên, vừa phức tạp đến mức không thể đoán hay bị crack, vừa không thể bị đánh cắp, và không thể bị mạo danh. Giải pháp như vậy được tìm thấy trong Cơ sở Hạ tầng Khóa công khai (PKI). Chúng tôi sẽ không đi sâu vào PKI ở đây vì nó là một chủ đề phức tạp, nhưng chúng tôi sẽ tóm tắt ngắn gọn cách nó hoạt động. Ý tưởng cơ bản sau PKI là bất cứ người dùng máy tính nào tạo ra một cặp khóa – một khóa công khai và một khóa riêng tư. Cả hai khóa đều được bảo mật bằng một mật khẩu mà chỉ người dùng biết, nhưng mật khẩu không cần thiết cho việc sử dụng khóa. Khi tạo khóa, thuật toán tạo ra một khối văn bản giao nhau mã hóa dài bên trong từng khóa gọi là hash mã học. Khóa riêng tư vẫn ở trên máy tính của người dùng trong một tập tin và không bao giờ được gửi hoặc cho đi – bao giờ. Khóa công khai thứ hai chứa một hash khác, nhưng vẫn liên quan đến khóa riêng tư. Chỉ thuật toán biết cách để giải mã và so sánh cả hai khóa. Do đó, chỉ thuật toán mới có thể xác nhận hoặc lừa bất kỳ cặp khóa nào. Cả hai khóa đều được yêu cầu cho giao tiếp vào mọi lúc. Một khóa mà không có khóa còn lại là không hữu ích và không hợp lệ. Sau khi thiết lập cặp khóa, người dùng công bố khóa công khai của họ trên internet. Một tập tin khóa công khai của người dùng cũng có thể được cho đi cho người khác để xác minh. Nhưng, khóa riêng tư của người dùng không bao giờ rời khỏi máy tính hoặc sở hữu. Khi một người dùng muốn kết nối với một máy chủ hoặc dịch vụ sử dụng PKI, người đó trước tiên yêu cầu quản trị viên của dịch vụ thêm khóa công khai của họ vào danh sách khóa được ủy quyền sống trên máy chủ hoặc dịch vụ. Danh sách này hoạt động như một loại danh sách người dùng được xác minh mà máy chủ có thể sử dụng trong quá trình xác thực người dùng. Tiếp theo, khi người dùng cố gắng kết nối với máy chủ hoặc dịch vụ từ xa, ứng dụng kết nối gửi một bắt tay từ máy tính của người dùng chứa khóa công khai của họ. Máy chủ tìm trong danh sách khóa biết được của mình, và nếu nó tìm thấy cùng một khóa công khai, nó sẽ gửi lại một thách thức đến máy tính yêu cầu: khóa riêng tư của bạn là gì? Nếu người gửi hợp lệ, và cùng máy tính cũng chuẩn, nó đọc, mã hóa, và gửi khóa riêng tư của người dùng an toàn qua mạng. Khi máy chủ nhận được khóa riêng tư, nó giải mã nó trên máy chủ, sau đó reverse-hash cả cặp khóa công khai và riêng tư của người dùng. Nếu thuật toán xác nhận rằng cặp khóa khớp nhau, nó xác thực người dùng, gửi lại một bắt tay xác nhận trở lại cho người gửi, và một kết nối an toàn, mã hóa được thiết lập. Kết quả của tất cả điều này, dĩ nhiên, là nếu không có khóa riêng tư tương ứng, giao tiếp là không thể. Không có mật khẩu gửi, không có tấn công người giữa để mạo danh máy chủ – người yêu cầu có khóa hay không – không có nguy cơ ở giữa. Nếu không, máy chủ sẽ từ chối kết nối. Hầu hết mọi hành động kết nối này diễn ra một cách tinh tế – mà không cần người dùng biết hoặc phải nghĩ về nó – máy chủ quan tâm chủ yếu là liệu có yêu cầu kết nối nào đó đến từ máy tính giữ khóa riêng tư khớp hoặc không. Nếu không, kết nối sẽ bị từ chối. Tất cả những điều này một phần làm giản dị hóa, nhưng trong bản chất là cách PKI hoạt động. PKI có lợi ích bổ sung là dễ sử dụng hơn và ít gây quấy rối hơn – một khi thiết lập và cài đặt, cặp khóa PKI loại bỏ nhu cầu sử dụng mật khẩu – không cần phải gõ một mật khẩu mỗi khi bạn đăng nhập vào một máy chủ. Danh tính của bạn được biết và được xác minh – và mật khẩu là điều đã qua. Sử dụng SSH trên Mac Hệ điều hành macOS của Apple, là một hệ thống UNIX đầy đủ, có hỗ trợ đầy đủ cho PKI tích hợp sẵn. Nó sử dụng OpenSSH – một phần của dự án OpenBSD. Thiết lập cặp khóa PKI của riêng bạn khá dễ dàng trên macOS. Khi khóa của bạn được cài đặt trên Mac của bạn, bạn ít khi cần truy cập trực tiếp đến chúng – chúng sẽ chủ yếu được sử dụng bởi các ứng dụng trong nền một cách im lặng. Trong macOS, các khóa SSH sống trong thư mục của mỗi người dùng, trong một thư mục ẩn gọi là .ssh. Thư mục này thường bị ẩn (vì lý do bảo mật) trừ khi bạn hiển thị các tệp ẩn trong Finder. Nếu bạn chưa bao giờ tạo cặp khóa PKI của mình, thư mục này có thể chưa tồn tại – nó được tạo ra bởi hệ thống khi bạn tạo ra các khóa. Có hai cách dễ dàng để tạo ra một cặp khóa PKI trong macOS. Bạn có thể sử dụng Terminal, hoặc một ứng dụng khoá chính thức thứ ba như GPGTools. Cách để tạo một cặp khóa PKI trong Terminal macOS Trong Terminal, gõ: ssh-keygen -b 4096 -t rsa… và nhấn Return. Bạn sẽ được nhắc chọn vị trí để lưu các tập tin khóa, và sau đó Terminal sẽ trả lời “Nhập tệp để lưu khóa vào (/Users/tênđăngnhập/.ssh/id_rsa)” Chỉ cần nhấn Return tại điểm này. Tiếp theo, bạn sẽ được nhắc điền mật khẩu để sử dụng cho các tập tin khóa. Trong hầu hết các trường hợp, chỉ cần nhấn Return. Bạn có thể nhập một mật khẩu nếu bạn muốn, nhưng lưu ý rằng mật khẩu không cần thiết cho việc trao đổi khóa: nó chỉ được sử dụng khi thực hiện các cải tiến cục bộ cho các tập tin khóa. Mật khẩu thường là dư thừa với PKI – khóa chính nó mới chính là bảo mật, và mật khẩu, như đã thảo luận, chung quy không an toàn. Lệnh UNIX ssh-keygen là một công cụ để sinh khóa. Có một loạt các tùy chọn và cài đặt cho việc sinh khóa. Bạn có thể xem tất cả các tùy chọn ssh-keygen bằng cách gõ “man ssh-keygen” trong Terminal và nhấn Return. Tùy chọn -b 4096 cho biết cho ssh-keygen tạo ra một khóa mạnh 4096 bit. Ở tốc độ siêu tính toán nhanh nhất thế giới hiện nay, mất hơn một trăm năm cho siêu máy tính nhanh nhất thế giới để đánh đến một khóa 4096 bit – điều đó có nghĩa là tính bảo mật của nó được đảm bảo. Cách để tạo ra một cặp khóa PKI bằng GPGTools Thay vì sử dụng Terminal để tạo khóa, bạn có thể tải xuống và cài đặt một ứng dụng khoá chính thức thứ ba như GPGTools. Khi đã tải xuống, chạy trình cài đặt. Khi trình cài đặt kết thúc, đóng nó lại, rồi mở ứng dụng GPG Keychain trong thư mục Ứng dụng của bạn. Nếu trên Mac của bạn chưa có bất kỳ khóa nào được cài đặt trước đó, GPG Keychain sẽ yêu cầu nhập địa chỉ email và mật khẩu để tạo khóa. Nhập thông tin phù hợp, rồi nhấp vào Generate. Sau một vài giây, các tập tin khóa sẽ được tạo trong thư mục .ssh, giống như ssh-keygen đã làm ở trên. Bằng cách nào đi nữa, bây giờ bạn có một thư mục .ssh ở trong thư mục cá nhân của bạn. Bên trong thư mục này, bạn sẽ thấy năm mục: authorized_keys (người dùng từ xa bạn muốn cho phép ssh xác minh để kết nối đến Mac của bạn) config (thông tin cấu hình ssh) id_rsa (khóa của bạn…)

The Secure Shell — SSH — allows you to send secure, encrypted, communications between computers that is nearly impossible to crack. Here’s how to use it in macOS.

Before personal computers, people used time-sharing terminals in computer labs which were attached to mainframe computers. Each user sat at a dumb terminal which was merely a display and keyboard connected to the mainframe computer. Later, as mini computers began to arrive, terminals were connected via a network.

Originally, to access another computer on a network remotely a program called Telnet was used. Telnet was one of the earliest internet applications, and was widely used in university and research settings. Security wasn’t considered an issue at the time, since most people still didn’t use the internet, and mass online fraud wasn’t a problem.

Internet commercialization in the 1990’s changed all that. As time went on, and with the advent of e-commerce, exchanging personal or financial data became ubiquitous.

Telnet still worked, but had one major flaw in the age of internet-everywhere: it sent and received all data in the clear as plain text. This included personal and financial info, and worst of all, passwords — anyone listening in on your network traffic could steal them.

To solve this problem, in 1999, Finnish developer Tatu Ylonen created the Secure Shell (SSH) – both a networking protocol and UNIX tool for sending and receiving data over unsecured networks by means of encryption combined with Public Key Infrastructure (PKI).

Public Key Infrastructure

One of the most difficult problems to solve in computer security is how to guarantee the authenticity of a remote user. Several techniques exist which hackers can use to impersonate users, and it’s difficult for servers and other users to insure impostors don’t gain unauthorized access.

Even long, difficult-to-guess passwords can be cracked by powerful supercomputers. Even the best passwords are insecure. And worst of all, passwords can be stolen.

What is needed is something more secure, which can be verified on both ends of a connection by both parties, which is complex enough not to be guessed or cracked, can’t be stolen, and which can’t be impersonated.

Such a solution is found in Public Key Infrastructure (PKI). We won’t go deep into PKI here as it’s a complex topic, but we’ll summarize briefly how it works.

The basic idea behind PKI is that any given computer user generates a pair of keys – one public, and one private. Both are secured with a password only the user knows, but the password isn’t required for key use.

At key generation, an algorithm creates a long encoded block of scrambled text inside each key called a cryptographic hash. The private key remains on the user’s computer in a file and is never sent or given out – ever. The second or “public” key contains a different hash, but one still related to the private one.

Only the algorithm knows how to unhash and compare both keys.

Hence, only the algorithm can verify or deny any given key pairs’ authenticity. Both keys are required for communication at all times. One key without the other is useless and invalid.

Once a key pair is established, the user publishes their public key on the internet. A user’s public key file can also be given out to others for verification purposes. But, the user’s private key never leaves their computer or possession.

When a user wants to connect to a server or service using PKI, he or she first asks that service’s administrator to add their public key to an authorized keys list which resides on the server or service. This list acts as a sort of verified users list the server can use during user authentication.

Next, when the user tries to connect to the remote server or service, the connecting app sends a handshake from the user’s computer containing their public key. The server looks in its list of known keys, and if it finds the same public key, it sends back a challenge to the requesting computer: what is your private key?

If the sender is legitimate, and the same computer as the original sender, it reads, encrypts, and sends the user’s private key securely over the network. When the server receives the private key, it decrypts it on the server, then reverse-hashes both the user’s public and private keys.

If the algorithm confirms that the key pair matches, it authenticates the user, sends a handshake confirmation back to the sender, and an encrypted, secure connection is established.

The upshot of all of this, of course, is that without the corresponding private key, communication is impossible. No passwords to send, no man-in-the-middle attacks to impersonate servers – the requester either has and sends the private key when challenged by the server or it doesn’t – there’s no middle ground.

Without it, the server will refuse the connection.

Most of this connection action happens transparently – without the user knowing or having to even think about it – all the server cares about is if any given connection request comes from the computer which holds the matching private key or not. If not, no dice. No exceptions.

All of this is a bit of an oversimplification, but in essence is how PKI works.

PKI has the added benefit of being easier to use and less obtrusive – once set up and installed, PKI key pairs eliminate the need for passwords – no more having to type a password every time you log in to a server. Your identity is known and guaranteed – and passwords are a thing of the past.

Using SSH on the Mac

Apple’s macOS, being a full UNIX system, has full support for PKI built-in. It uses OpenSSH – which is part of the OpenBSD project. Setting up your own PKI key pair is fairly easy in macOS. Once your keys are installed on your Mac, you’ll rarely need to access them directly – they will mostly be used by applications in the background silently.

In macOS, SSH keys live in each user’s folder, in a hidden folder called .ssh. This folder is normally hidden (for security reasons) unless you show invisible files in the Finder. If you haven’t yet generated your PKI keys, this folder probably won’t exist – it gets created by the system when you generate the keys.

There are two easy ways to generate a PKI key pair in macOS. Either the Terminal, or a third-party keychain app such as GPGTools can be used.

How to generate a PKI key pair in macOS Terminal

In Terminal type:

ssh-keygen -b 4096 -t rsa

…and press Return.

You’ll be prompted for a location to save the key files, with the Terminal responding “Enter file in which to save the key (/Users/username/.ssh/id_rsa)” Just press Return at this point.

Next, you’ll be prompted for a password to use for the key files. In most cases, just press Return. You can enter a password if you want, but note that this password is not needed for key exchange: it’s only used when making local modifications to the key files themselves.

Passwords generally are redundant with PKI – the keys themselves are the security, and passwords, as already discussed, are in general insecure.

The ssh-keygen UNIX command is a tool to generate keys. There are a variety of options and settings for key generation. You can view all ssh-keygen options by typing “man ssh-keygen” in Terminal and pressing Return.

The -b 4096 option tells ssh-keygen to generate a 4096-bit strong key. At current world supercomputing speeds, it takes the fastest supercomputers on earth over one-hundred years to crack a 4096-bit key – which means their security is guaranteed.

How to generate a PKI key pair using GPGTools

Instead of using Terminal to generate keys, you can download and install a third-party keychain app such as GPGTools. Once downloaded, run the installer. When the installer finishes, close it, then open the GPG Keychain app in your Applications folder.

If no keys were previously installed on your Mac, GPG Keychain will prompt for an email address and password to use for key generation. Enter appropriate info, then click Generate. After a few seconds key files will be created in an .ssh folder, just as ssh-keygen did above.

Either way, you now have an .ssh folder inside your user folder. Inside this folder you’ll find five items:

  1. authorized_keys (remote users you want to allow ssh to authorize to connect to your Mac)
  2. config (ssh config info)
  3. id_rsa (your private key)
  4. id_rsa.pub (your public key)
  5. known_hosts (a list of known remote servers you want to allow to connect to your Mac).

If you open your id_rsa.pub key file in a text editor such as TextEdit, you’ll see your public key, followed by your local machine’s user and machine name. For example:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFYeQoBHJD4aNtuJrClanz02mDC74O/qkVuWqMxSFqTohEB/o/E5eUYia+wPnSRHSo8W2aQo69wZusWXqSMIltjsvadsU51v0j1dw9f3pJNsOQEfOQhVq78HGti+crSI7R/1umbGHkLAUldpEEOhcOqFI+/3UeXTX93SMd1VhD14k32blma8fwbzTY9AUx0osD7FOJWK/Wz7YDEuxjnFmrHUzuPmzDQQGjYR0S8FaO7ICSeoPIzic0ysgWjwcNtfQnDODEXkt+AhWeQUzIdFSMhrxjPDT5fVUbocPwNgCCtDLwnZ74MrFjgm0hARrN+IcyFXbSPkO4KCOOXl1J1n+H (email protected)

In fact, do that now: navigate to your Users/~/.ssh folder, open id_rsa.pub in a text editor, and copy the entire thing.

Since both the public and private keys are stored in the two files as text, make sure your private key file is never compromised: if someone else gains access to your private key, they can install it onto another computer and impersonate you.

If all you care about is outgoing connections to remote servers, then you don’t need to worry about most of these files except id_rsa and id_rsa.pub. The other three files are generally used in a server setting for incoming connection requests from other computers. In most cases you won’t need to think about them.

Be sure to make backups of your id_rsa and id_rsa.pub files in a safe place immediately.

Once your key setup is complete, your .ssh folder should look something like this:

The known_hosts file may or may not get generated by the system until the first time you use SSH to connect to a server, but we’ll discuss that file below.

Server side

Now that your keys are in place and ready for use, you must set up whatever server/service you want to connect to so that they use PKI instead of passwords. How to do this varies depending on your server hosting service.

If your server host is a web hosting service which offers cPanel or a similar web frontend, those services usually offer a section in the cPanel called “Security” or “Terminal”. You’ll need to log in to your cPanel first, then go to the Security pane:

Next, click on “SSH Access”, then click the “Manage SSH Keys” button:

Next, click “Import Key”:

On the next page, fill in a name for the key in the top box (the name doesn’t matter), and in the public key field, paste in your public key:

Usually this field has a caption of “Paste the public key into the following text box:” or something similar.

Do not paste anything into the private key text box. This is usually named “Paste the private key into the following text box:”.

While technically your cPanel and web host are secure, you don’t want to take any chances. Besides, it’s not needed — when your computer tries to connect to the server using SSH, the server will ask your local computer for your private key at handshake time.

If you did enter a key password at key generation time, enter it in the “Passphrase” field, otherwise leave this field blank.

Next, click the Import, then the Go Back buttons.

Your public key is now imported to your cPanel and web host, but you still need to authorize it before you can use it. On the cPanel page under “Public Keys” you’ll now see your key listed but you’ll see “unauthorized” next to it. Click the Manage button.

On the next page, click the Authorize button, then the Go Back button. Back on the previous page you should now see “authorized” next to your public key in the list.

If the server you are connecting to doesn’t provide a cPanel or other web interface and only offers bare metal access, you will need to contact your sever admin to have them install your public key. In most cases on UNIX or Linux servers, this is done in the sshd.conf and ssh.conf files, but your mileage may vary, depending on what OS and server software your server is running.

Connecting

Now that your keys are installed, and your server knows how to use them, it’s time to try a connection.

You can test the connection in Terminal by opening a terminal window and typing “ssh username@ip-address” and pressing Return.

Alternatively, you can type “ssh username@domain-name” and press Return.

In the first case you need to know your server’s IP address, and in the second case, you need to know your domain name. On cPanel-based systems, the username is usually the same as your cPanel name, but may be different depedning on how your web host company configured your server.

The default UNIX port SSH connects on is port 22, but most web host providers will have changed the SSH port number to something else for security reasons. If this is the case, you need to know the port number and specify it using the -p option in the ssh command. For example:

ssh -p 4612 username@ip-address

See the “ssh man” page for more info on using the -p command. If you don’t know the port number, you’ll need to contact your web host provider, or see if it’s mentioned in their online knowledgebase.

Once the above command is executed, your Mac will initiate an SSH session with the server, starting with a handshake in which it sends your public key. The server will then respond by asking for your Mac’s private key. The built-in SSH machinery will read it from disk and send it back to the server in the response.

All of this will happen silently.

Once the server decodes your two keys and verifies them, if it finds they match, it will send a confirmation back to your Mac. If successful, you may see a cryptic message in Terminal such as:

The authenticity of host 'example.domain.com (192.168.2.155)' can't be established. RSA key fingerprint is 45:83:45:4a:e3:29:7e:fa:f3:c3:7d:64:ea:3a:6f:58. Are you sure you want to continue connecting (yes/no)?

Type yes and press Return.

Terminal will most likely print a message similar to: Warning: Permanently added ‘example.domain.com,192.168.2.155’ (RSA) to the list of known hosts.

You only need to do this the first time you connect to each server via SSH. After that your Mac will have added that server’s info to your local known_hosts file. Next time you initiate the same SSH connection, it will first look for the server in the known_hosts file. If it finds it, it will connect without displaying any of the above.

Once connected via an SSH connection, all communications between both computers in Terminal including all text and commands you type will be sent and received over a secure, encrypted connection.

Also be aware that if you are using a VPN and it’s connected in another country, your web host provider may deny all remote SSH connections. This is to prevent hackers in other countries from gaining access to your web host. In such cases, you’ll have to disable your VPN and try again.

Since we’re on the subject of VPN’s it’s a good time to talk about…

SSH Tunneling

What you did in the above example was to create a connection based on SSH Tunneling. Tunneling simply means that a connection has created a secure “tunnel” in which all communications in both directions are fully encrypted. Even if a man-in-the-middle attacker intercepts your communications or impersonates you, the data transfered between the two computers is still fully encrypted.

Without access to your private key, an attacker still can’t decrypt your data.

Most commercial and free VPN clients use such tunnellng on various ports to VPN servers in other countries. In fact, most VPN connections will send and receive data across many such servers per session. In most VPN server configurations, there is also a dedicated SSH server located elsewhere, but SSH may also reside on the same VPN server (which is considered a bad security practice).

As your data traverses your VPN, it becomes more and more difficult for anyone eavesdropping on your communications to tell where the data originated, and where it is going. The tunneling encryption adds one more level of security.

SSH Connections Using GUI Apps

Where SSH’s power really shines on the Mac is when using a networking app (such as an FTP client) with a graphical user interface. In such cases, most apps allow you to specify your public key once, then as soon as you make a new connection it just works – no passwords, no more prompts, no hassles.

Everything happens behind the scenes which makes connecting a breeze.

For example, the excellent Transmit app by Panic has a public key button in the connection window:

Clicking the key icon displays a small window which will show your default public key, if it’s installed on your system:

Click your public key, it will be set, and the small key icon in the connection window will turn green:

Now enter your server’s address, custom SSH port, if any, user name, and path on the server you want to access.

Click Connect.

If all goes well Transmit will connect and you won’t be prompted for a password. Transmit may prompt you with a GUI version of the “authenticity of host can’t be established” message the first time you connect, but if you confirm the dialog, it will add the server info to the known_hosts file just like in the Terminal example above.

The next time you make the same connection in Transmit, it should be seamless: no passwords, no prompts, no nothing.

In order to send and receive all FTP data securely, you must use the SFTP protocol instead of plain FTP.

You can also save the connection window settings to Favorites in Transmit and then simply select it from the Favorites list next time for an instant connection – Transmit will remember your key each time automatically.

Panic has a short instructions page on adding SSH keys to connections.

SSH is a powerful part of UNIX infrastructure and we’ve barely scratched the surface. For a deep dive into SSH, consult a good book such as O’Reilly’s SSH: The Secure Shell. You can find a used copy on eBay for around $20.

Using SSH for secure connections can speed up your workflow on the Mac because you won’t need to enter passwords again. Setup takes a little work, but once your keys are installed and servers configured, you’ll wonder how you got along without it.

KẾT LUẬN SSH được sử dụng để gửi thông tin an toàn, mã hóa giữa các máy tính mà gần như không thể bị giải mã. Để sử dụng trên macOS, tất cả thông tin sẽ được gửi và nhận dữ liệu thông qua mạng không an toàn bằng cách mã hóa kết hợp với hạ tầng khóa công khai (PKI). PKI là một cách để đảm bảo tính xác thực của người dùng từ xa, giúp ngăn chặn muôn loài hacker có thể giả mạo người dùng. Khi đã được cài đặt và sử dụng trên Mac, cài đặt và sử dụng cặp khóa PKI sẽ giúp loại bỏ vấn đề về việc gõ mật khẩu mỗi khi đăng nhập vào máy chủ. Điều quan trọng nhất là, PKI không gì sẽ làm mất tính riêng tư của bạn. Để sử dụng PKI trên Mac, bạn có thể sử dụng Terminal hoặc ứng dụng GPGTools. Bất kể cách nào bạn sử dụng, khi hoàn tất quy trình, bạn sẽ có thể thấy folder .ssh trong thư mục người dùng, và khi mở nó, bạn sẽ thấy năm mục khóa khác nhau. Đây là những bước cơ bản để sử dụng SSH trên Mac.

Để lại một bình luận