Fixed SSH on macOS for /etc/services
This commit is contained in:
parent
1ae90725d6
commit
ed1a4b5292
3 changed files with 18 additions and 4 deletions
|
@ -158,7 +158,7 @@ data:
|
|||
allowTCPForwarding: no
|
||||
allowUsers: {{ env "USER" }}
|
||||
endlesshPort: 22
|
||||
port: 2214
|
||||
port: 8169
|
||||
vpn:
|
||||
excludedSubnets:
|
||||
- 10.0.0.0/24
|
||||
|
|
|
@ -325,10 +325,20 @@ configureSSHD() {
|
|||
### Restart SSH server
|
||||
if [ -d /Applications ] && [ -d /System ]; then
|
||||
### macOS
|
||||
if [ -f /etc/services ]; then
|
||||
logg info 'Updating SSH configuration in /etc/services to point to port {{ .host.ssh.port }}'
|
||||
sudo sed -i.bak 's/ 22\/udp/ {{ .host.ssh.port }}\/udp/' /etc/services
|
||||
sudo sed -i.bak 's/ 22\/tcp/ {{ .host.ssh.port }}\/tcp/' /etc/services
|
||||
sudo rm -f /etc/services.bak
|
||||
fi
|
||||
logg info 'Running sudo systemsetup -setremotelogin on' && sudo systemsetup -setremotelogin on > /dev/null
|
||||
logg info 'Running sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist' && sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist 2> /dev/null
|
||||
logg info 'Running sudo launchctl stop com.openssh.sshd' && sudo launchctl stop com.openssh.sshd
|
||||
logg info 'Running sudo launchctl start com.openssh.sshd' && sudo launchctl start com.openssh.sshd && logg info 'Successfully ran launchctl start com.openssh.sshd'
|
||||
if sudo launchctl list | grep 'com.openssh.sshd' > /dev/null; then
|
||||
logg info 'Unloading previous com.openssh.sshd configuration'
|
||||
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
|
||||
fi
|
||||
logg info 'Running sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist (Latest)' && sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
|
||||
logg info 'Running sudo launchctl stop com.openssh.sshd (High Sierra - errors muted)' && sudo launchctl stop com.openssh.sshd 2> /dev/null
|
||||
logg info 'Running sudo launchctl start com.openssh.sshd (High Sierra - errors muted)' && sudo launchctl start com.openssh.sshd 2> /dev/null && logg info 'Successfully ran launchctl start com.openssh.sshd'
|
||||
else
|
||||
### Linux
|
||||
logg info 'Enabling the sshd service'
|
||||
|
|
|
@ -29,6 +29,10 @@ Host gitlab.com
|
|||
Host github.com
|
||||
UpdateHostKeys no
|
||||
IdentityFile ~/.ssh/id_rsa
|
||||
Host macbook-pro
|
||||
User {{ .user.username }}
|
||||
Hostname ssh-macbook-pro.{{ .host.domain }}
|
||||
ProxyCommand /opt/homebrew/bin/cloudflared access ssh --hostname %h
|
||||
{{ if (lookPath "fig") -}}
|
||||
Match all
|
||||
Include ~/.fig/ssh
|
||||
|
|
Loading…
Reference in a new issue