Mac如何通过终端开启/关闭SSH

本文介绍如何在Mac上检查SSH服务的状态,并提供开启和关闭SSH服务的具体命令。SSH是一种安全协议,用于远程登录会话及其它网络服务,确保远程管理过程中信息的安全。
部署运行你感兴趣的模型镜像

一般较新的Mac设备默认都会预装SSH,不过SSH守护进程默认是关闭禁用的,那么如何开启它呢,下面就来讲一讲。

一、介绍:

SSH 为 Secure Shell 的缩写,由 IETF 的网络小组(Network Working Group)所制定;SSH 为建立在应用层基础上的安全协议。SSH 是目前较可靠,专为远程登录会话和其他网络服务提供安全性的协议。利用 SSH 协议可以有效防止远程管理过程中的信息泄露问题。SSH最初是UNIX系统上的一个程序,后来又迅速扩展到其他操作平台。SSH在正确使用时可弥补网络中的漏洞。SSH客户端适用于多种平台。几乎所有UNIX平台—包括HP-UXLinuxAIXSolarisDigital UNIXIrix,以及其他平台,都可运行SSH。

二、检测SSH是否开启

检测命令:sudo systemsetup -getremotelogin

如下图:(关闭状态)


三、开启、关闭SSH

开启命令:sudo systemsetup -setremotelogin on
关闭命令:sudo systemsetup -setremotelogin off



您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

ubuntu@VM-0-6-ubuntu:~$ ssh -R 13306:127.0.0.1:3306 -R 18088:127.0.0.1:8088 -i "C:\Windows\My_Superset_Key.pem" ubuntu@43.153.66.149 -N -v Warning: Identity file C:\Windows\My_Superset_Key.pem not accessible: No such file or directory. OpenSSH_9.6p1 Ubuntu-3ubuntu13.14, OpenSSL 3.0.13 30 Jan 2024 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for * debug1: Connecting to 43.153.66.149 [43.153.66.149] port 22. debug1: Connection established. debug1: identity file /home/ubuntu/.ssh/id_rsa type -1 debug1: identity file /home/ubuntu/.ssh/id_rsa-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_ecdsa type -1 debug1: identity file /home/ubuntu/.ssh/id_ecdsa-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_ecdsa_sk type -1 debug1: identity file /home/ubuntu/.ssh/id_ecdsa_sk-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_ed25519 type -1 debug1: identity file /home/ubuntu/.ssh/id_ed25519-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_ed25519_sk type -1 debug1: identity file /home/ubuntu/.ssh/id_ed25519_sk-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_xmss type -1 debug1: identity file /home/ubuntu/.ssh/id_xmss-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_dsa type -1 debug1: identity file /home/ubuntu/.ssh/id_dsa-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.14 debug1: Remote protocol version 2.0, remote software version OpenSSH_9.6p1 Ubuntu-3ubuntu13.14 debug1: compat_banner: match: OpenSSH_9.6p1 Ubuntu-3ubuntu13.14 pat OpenSSH* compat 0x04000000 debug1: Authenticating to 43.153.66.149:22 as 'ubuntu' debug1: load_hostkeys: fopen /home/ubuntu/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen /home/ubuntu/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: sntrup761x25519-sha512@openssh.com debug1: kex: host key algorithm: ssh-ed25519 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: SSH2_MSG_KEX_ECDH_REPLY received debug1: Server host key: ssh-ed25519 SHA256:SCNCIXYAS8UyHXm9xBmwatnCfmtTo1JQSU6B6FLMhJE debug1: load_hostkeys: fopen /home/ubuntu/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen /home/ubuntu/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: hostkeys_find_by_key_hostfile: hostkeys file /home/ubuntu/.ssh/known_hosts does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file /home/ubuntu/.ssh/known_hosts2 does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file /etc/ssh/ssh_known_hosts does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file /etc/ssh/ssh_known_hosts2 does not exist The authenticity of host '43.153.66.149 (43.153.66.149)' can't be established. ED25519 key fingerprint is SHA256:SCNCIXYAS8UyHXm9xBmwatnCfmtTo1JQSU6B6FLMhJE. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '43.153.66.149' (ED25519) to the list of known hosts. debug1: ssh_packet_send2_wrapped: resetting send seqnr 3 debug1: rekey out after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: Sending SSH2_MSG_EXT_INFO debug1: expecting SSH2_MSG_NEWKEYS debug1: ssh_packet_read_poll2: resetting read seqnr 3 debug1: SSH2_MSG_NEWKEYS received debug1: rekey in after 134217728 blocks debug1: SSH2_MSG_EXT_INFO received debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256> debug1: kex_ext_info_check_ver: publickey-hostbound@openssh.com=<0> debug1: kex_ext_info_check_ver: ping@openssh.com=<0> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: SSH2_MSG_EXT_INFO received debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256> debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Will attempt key: /home/ubuntu/.ssh/id_rsa debug1: Will attempt key: /home/ubuntu/.ssh/id_ecdsa debug1: Will attempt key: /home/ubuntu/.ssh/id_ecdsa_sk debug1: Will attempt key: /home/ubuntu/.ssh/id_ed25519 debug1: Will attempt key: /home/ubuntu/.ssh/id_ed25519_sk debug1: Will attempt key: /home/ubuntu/.ssh/id_xmss debug1: Will attempt key: /home/ubuntu/.ssh/id_dsa debug1: Trying private key: /home/ubuntu/.ssh/id_rsa debug1: Trying private key: /home/ubuntu/.ssh/id_ecdsa debug1: Trying private key: /home/ubuntu/.ssh/id_ecdsa_sk debug1: Trying private key: /home/ubuntu/.ssh/id_ed25519 debug1: Trying private key: /home/ubuntu/.ssh/id_ed25519_sk debug1: Trying private key: /home/ubuntu/.ssh/id_xmss debug1: Trying private key: /home/ubuntu/.ssh/id_dsa debug1: Next authentication method: password ubuntu@43.153.66.149's password: Authenticated to 43.153.66.149 ([43.153.66.149]:22) using "password". debug1: Remote connections from LOCALHOST:13306 forwarded to local address 127.0.0.1:3306 debug1: Remote connections from LOCALHOST:18088 forwarded to local address 127.0.0.1:8088 debug1: ssh_init_forwarding: expecting replies for 1 forwards debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: pledge: filesystem debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0 debug1: client_input_hostkeys: searching /home/ubuntu/.ssh/known_hosts for 43.153.66.149 / (none) debug1: client_input_hostkeys: searching /home/ubuntu/.ssh/known_hosts2 for 43.153.66.149 / (none) debug1: client_input_hostkeys: hostkeys file /home/ubuntu/.ssh/known_hosts2 does not exist debug1: Remote: Forwarding listen address "localhost" overridden by server GatewayPorts debug1: remote forward success for: listen 13306, connect 127.0.0.1:3306 debug1: forwarding_success: all expected forwarding replies received debug1: Remote: Forwarding listen address "localhost" overridden by server GatewayPorts debug1: remote forward success for: listen 18088, connect 127.0.0.1:8088 Learned new hostkey: RSA SHA256:bMnW71Qezpmj4tukHMhu0x0VpvJieee1wdgc60q2EYQ Learned new hostkey: ECDSA SHA256:S6pP7Ec/rv08+KrvN0RqH8YIG3kkN5luqKxKJ69NkJE Adding new key for 43.153.66.149 to /home/ubuntu/.ssh/known_hosts: ssh-rsa SHA256:bMnW71Qezpmj4tukHMhu0x0VpvJieee1wdgc60q2EYQ Adding new key for 43.153.66.149 to /home/ubuntu/.ssh/known_hosts: ecdsa-sha2-nistp256 SHA256:S6pP7Ec/rv08+KrvN0RqH8YIG3kkN5luqKxKJ69NkJE debug1: update_known_hosts: known hosts file /home/ubuntu/.ssh/known_hosts2 does not exist debug1: pledge: network debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1 debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1 debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1 debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1
最新发布
11-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值