Diary

[Mac] Limiting VPN Connection Destinations

1 Mins read

When connected to a VPN, route traffic destined for networks outside the VPN connection (non-VPN destination networks) directly through your local network instead of through the VPN tunnel. This keeps network traffic responsive.

※If you’re working remotely, check with your IT department first—some organizations require all traffic to route through internal networks.

※Be aware that many external servers are configured to allow access only through the VPN tunnel.

※If accessing the VPN destination by domain name, watch out for DNS settings. Depending on the VPN’s DNS configuration, you may need to edit the hosts file.

macOS Monterey
Version 12.3
VPN Connection Method: L2TP/IPsec (PPP tunneling)

■Open Network Settings and access VPN connection details
Uncheck “Send all traffic over VPN connection”
設定画像

■Create a routing addition script
The /etc/ppp/ip-up script is executed when the connection is established.
Add the following to this file to “add IP routes when VPN connects”.
In this example, “172.31.1.0/24” is the route you want to send through the VPN.

#Confirm ppp0 exists after VPN connection
$ ifconfig

#After disconnecting the VPN
#Edit the file with vi
$ sudo vi /etc/ppp/ip-up
#!/bin/sh

if [ "$1" = "ppp0" ]; then
    /sbin/route add -net 172.31.1.0/24 -interface ppp0
fi

#Save the file in vi
#Give the file execute permission
$ sudo chmod +x /etc/ppp/ip-up

#Check the routing table
$ netstat -rn

Notes
When routing multiple paths, you can add multiple entries:
/sbin/route add -net 172.31.1.0/22 -interface ppp0
/sbin/route add -net 172.31.4.0/22 -interface ppp0
/sbin/route add -net 172.31.8.0/22 -interface ppp0

Read more
Diary

[Mac] rbenv openssl [BUILD FAILED] [make: *** [all] Error 2]

1 Mins read

Needed an old environment so hit this issue setting up Xcode and Ruby on a legacy Mac. Leaving a note.

20220315

■Environment
macOS High Sierra 10.13.6
Homebrew 3.4.1-67-gb31d8e9
rbenv 1.2.0

Got this error:

Downloading openssl-1.1.1l.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
Installing openssl-1.1.1l...

BUILD FAILED (Mac Os X 10.13.6 using ruby-build 20220218)

Inspect or clean up the working tree at /var/folders/rc/9hwgt2nd0rxgjzvt9kc0zgph0000gn/T/ruby-build.20220315231102.889.ggie1q
Results logged to /var/folders/rc/9hwgt2nd0rxgjzvt9kc0zgph0000gn/T/ruby-build.20220315231102.889.log

Last 10 log lines:
/usr/include/CommonCrypto/CommonRandom.h:35:9: error: unknown type name 'CCCryptorStatus'
typedef CCCryptorStatus CCRNGStatus;
        ^
crypto/rand/rand_unix.c:385:47: error: use of undeclared identifier 'kCCSuccess'
    if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
                                              ^
2 errors generated.
make[1]: *** [crypto/rand/rand_unix.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

So you need OpenSSL 1.0. This command installs “rbenv/tap/openssl@1.0 1.0.2t”:

#Install OpenSSL1.0
brew install rbenv/tap/openssl@1.0

#Set environment variable [hoge is your username]
echo 'export PATH="/usr/local/opt/openssl@1.0/bin:$PATH"' >> /Users/hoge/.bash_profile
#Reflect environment variable
source .bash_profile

#If needed, reflect environment variable
export LDFLAGS="-L/usr/local/opt/openssl@1.0/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.0/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.0/lib/pkgconfig"

#This is needed for subsequent commands!
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl@1.0`"

#Install whatever Ruby version you want
rbenv install 2.6.9

On macOS, OpenSSL affects other things too.

OpenSSL also impacts the mysql2 library used by Rails and others. Watch out if you’re using MySQL 5.6 or 5.7!

Before running bundle install, you need to set this in your .bundle/config file:

BUNDLE_BUILD__MYSQL2: "--with-ldflags=-L/usr/local/opt/openssl@1.0/lib --with-cppflags=-I/usr/local/opt/openssl@1.0/include"
Read more
Diary

[GitHub] SSH Public Key Gets Deleted [git@github.com: Permission denied (publickey).]

1 Mins read

Github


$ ssh -T git@github.com
$ git@github.com: Permission denied (publickey).

Huh?

The .ssh directory itself looks fine.

Checked logs with

ssh -vT git@github.com

or

ssh -vvv git@github.com

Error traces point to the key.

Checked Github SSH Key on the web page.

It’s gone!

Turns out SSH public keys have an expiration date and get automatically deleted.

Recreated and set it up. Problem solved.

Read more
Diary

[Github] Repository Access Method Changed [remote: Support for password authentication was removed on August 13, 2021.]

1 Mins read

Github’s access method has changed.

「git push -u origin develop」

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.

Password authentication is now deprecated and replaced with access token method.

You need to log into Github on the web and create an access token.

1.Open the settings page( https://github.com/settings/tokens )
2.Click [Generate new token]
3.Enter an appropriate token name in the note field
4.Set permissions (need at least [repo] permission if modifying repositories)
5.Click [Generate token]
6.Save the generated token ★Important! Copy the token displayed here

★[repo] permission required to access repositories
★[workflows] permission required to update GitHub Actions
★Due to security constraints, token expiration can only be set up to max 360 days

git push -u origin develop
Username for 'https://github.com': hogehoge
Password for 'https://hogehoge@github.com':★

hogehoge = username
★ = token
You can now access with these credentials

Read more