Fixing “percent_expand: NULL replacement” SSH bug on OS X Leopard
Apple decided to fix up some of their UNIX functions to operate more like the standard, but they didn’t test very thoroughly because they broke the SSH client Update: Actually, this is a problem with MacPorts, Apple’s SSH still works (if you see “percent_expand: NULL replacement”, you’ve hit the bug). They’ll probably fix this, but if you need a quicker solution, here it is.
- Download the latest OpenSSH and untar it to the desktop (Link)
- Go into this directory and open up “ssh.c”
- Make the following patch near line 1252 (Leave out the ‘+’):
Code Sample:#endif /* SMARTCARD */
if ((pw = getpwuid(original_real_uid)) == NULL)
fatal("load_public_identity_files: getpwuid failed");
+ pw = pwcopy(pw);
if (gethostname(thishost, sizeof(thishost)) == -1)
fatal("load_public_identity_files: gethostname: %s",
strerror(errno)); - Open up the terminal, and run the following commands:
Code Sample:cd ~/Desktop/openssh-4.7p1
./configure --exec-prefix=/usr/local --prefix=/
make
sudo make install







Entries RSS
vulgarisoip said,
October 29, 2007 @ 10:18 am
Use the above instructions with the following configure command:
./configure --exec-prefix=/opt/local --prefix=/
To overwrite broken MacPorts version
Steve said,
October 29, 2007 @ 5:02 pm
An even quicker fix is to rename the ’scp’ and ’ssh’ binaries in /opt/local/bin, and symlink to the working Apple versions shipped with Leopard in /usr/bin.
That way, programs like git that explicitly look for ssh in /opt/local/bin will continue to work.
I’ll look at submitting a macports patch if nobody else has done so already.
Steve said,
October 30, 2007 @ 3:40 am
Update: I’ve submitted a patch to MacPorts, so hopefully the issue will go away soon:
http://trac.macosforge.org/projects/macports/ticket/13046
Paul Betts said,
October 30, 2007 @ 12:12 pm
@vulgarisoip: Even better - when I wrote this article, I thought it was the Apple ssh that was broken, so that’s a better fix
@steve: I didn’t want to suggest that, because I didn’t know the differences between Apple’s ssh and MacPorts’ ssh. Thanks for submitting the patch though, good work!
Travis Vachon said,
November 2, 2007 @ 8:55 pm
An even nicer solution can be found here:
http://www.nabble.com/ssh:-percent_expand:-NULL-replacement-t4701144.html
Worked like a charm for me.
fablamenas said,
November 10, 2007 @ 9:48 am
thanks for your help. I was crazy with that. I used the link provided by Travis Vachon… Easier to test first and worked fine… so far enough for me. thanks.