What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

How to make ssh settings permanent

Zigster

Occasional Visitor
Hi Forum,

I installed a sd-card to the internal sd-slot of my asus rt-n66u (running the latest merlin).

However, when I configure an ssh key to the user's authorized_keys file, this works only until restarting the router (or reconfigure any value and then saving the changes).

So my question is, how can I make those changes permanent?

Thanks for hints on that :-)

Zigster
 
Are web-gui settings not suitable for some reason?
(Administration - System - SSH Authentication key)

AFAIK, it's stored in nvram as sshd_authkeys, copied to /home/root/.ssh/authorized_keys during boot and does not concern external SSD card.
But you can, of course, mount your SSD on /home if you want.
 
One more thing:

Suppose, I want to connect FROM the Asus TO any other host in my Network via SSH PubKey Authentication using keys generated from dropbearkey:

Therefore I'd need a place to create & store the (public and) private key on the asus:

Where would that place permanently be (using an internally installed sdcard) ?

Thanks for a tip !!

Zigster
 
You could probably create a symbolic link, something like /mnt/sd?1/.ssh/AuthKeys to /home/root/.ssh/AuthKeys. Once you figure out the proper command add it to a user script like PostMount if it doesnt stay linked on reboot.
 
Last edited:
Ok, I see you definitely want to use your internal micro-SD.

I'd do next:
1. Format it in ext2.
2. Give it a label.
3. Mount to /opt via label and /jffs/configs/fstab:
Code:
LABEL=myopt             /tmp/opt        ext2            rw,noatime      1 1
4. Make there a home directory for users.
5. Mount this directory on /tmp/home/ via /jffs/scripts/services-start/:
Code:
#!/bin/sh
mount -obind /opt/home /tmp/home
You'll have your keys saved permanently there.
Moreover, you'll have many other settings (mc settings, etc.) saved there permanently.
An you can now install entware if you want to.
 
@Zigster
To say the truth, I have a storage device mounted on /home for a long time on several routers and many firmwares.
It has some advantages and disadvantages but it works for my purposes.

If you have only one storage device connected permanently, it's logical to mount it on /opt for entware.
But you can, of course, use some space on it for /home :)
 
Hi bbsc,

tried your steps (labeled my sdcard partition with SDCARD), but upon reboot, the /jffs/scripts/services-start doesn't seem to be executed (it is chowned with a+x), as the mount point doesn't show up on executing "mount".

What am I missing out ?

Thanx again :)

Zigster
 
I'm awfully sorry, I've missed one thing: there's no /tmp/opt directory by default.
Please make a /jffs/scripts/init-start executable file like this:
Code:
#!/bin/sh
mkdir -p /tmp/opt

Of course, your fstab must be like this:
Code:
LABEL=SDCARD             /tmp/opt        ext2            rw,noatime      1 1

And I hope you've labled that partition with linux command like:
Code:
tune2fs -L SDCARD /dev/sda1
:)
 
Hi bbsc,

yep labeling was done, just as you wrote,

I have two scripts now in /jffs/scripts/

Code:
ll /jffs/scripts/
-rwxrwxrwx    ...  init-start*
-rwxrwxrwx    ...  services-start*
where init-start is exactly like the one in your last post and services-start has:
Code:
#!/bin/sh
mount -obind /opt/home /tmp/home
But still, the script isn't mounting on bootup.

Interestingly, when I run the services-start script manually, the mount is done and then I see the following:
Code:
/dev/sda1 on /tmp/opt type ext2 (rw,noatime)
/dev/sda1 on /tmp/home type ext2 (rw,noatime)
Which is weird, as it is mounted twice then ...

Thanks again...

Zigster
 
Last edited:
Hi,
Mounted twice?
It's normal as you mount device /dev/sda1 on /tmp/opt and then mount directory /opt/home on /tmp/home.

I have no idea why the script does not work during boot.
Check the spelling, etc.

I have here a RT-N66U with micro-SD inserted and the same script works well.
Look, the micro-SD is inserted and formatted in ext2:
Code:
ASUSWRT-Merlin RT-N66U_3.0.0.4 Fri Jan 31 05:20:15 UTC 2014
admin@RT-N66U-CK:/tmp/home/root# fdisk -l

Disk /dev/sda: 1015 MB, 1015021568 bytes
32 heads, 61 sectors/track, 1015 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1        1015      990609+ 83 Linux

The partition is labeled as myopt:
Code:
admin@RT-N66U-CK:/tmp/home/root# blkid
/dev/sda1: LABEL="myopt" UUID="3572e59c-e8ea-47f9-ac0a-8511cd51c340"

/tmp/opt is created during boot:
Code:
admin@RT-N66U-CK:/tmp/home/root# cat /jffs/scripts/init-start
#!/bin/sh

mkdir -p /tmp/opt

It's the mount-point of the device with "myopt" label:
Code:
admin@RT-N66U-CK:/tmp/home/root# cat /jffs/configs/fstab
LABEL=myopt             /tmp/opt        ext2            rw,noatime      1 1

And directory /opt/home on micro-SD is mounted on /tmp/home:
Code:
admin@RT-N66U-CK:/tmp/home/root# cat /jffs/scripts/services-start
#!/bin/sh

mount -obind /opt/home /tmp/home

This is the result:
Code:
admin@RT-N66U-CK:/tmp/home/root# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock4 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw)
[B]/dev/sda1 on /tmp/opt type ext2 (rw,noatime)
/dev/sda1 on /tmp/home type ext2 (rw,noatime)[/B]
 
Last edited:
formatting

Hi bbsc,

thank you for your explanatory post.

While verifying thr partitions on the sd card I noticed the following:

After a fresh reboot, fdisk -l shows the following
Code:
fdisk -l

Disk /dev/sda: 3963 MB, 3963617280 bytes
128 heads, 63 sectors/track, 960 cylinders
Units = cylinders of 8064 * 512 = 4128768 bytes

Device Boot      Start         End      Blocks  Id System
/dev/sda1               2         960     3866624   b Win95 FAT32

So I tried to delete that partition with fdisk
Code:
fdisk /dev/sda1
d
1

and repartition it with a linux partition
Code:
fdisk /dev/sda1
n
p
1
w

On exiting, fdisk states the following:

Code:
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table
fdisk: WARNING: rereading partition table failed, kernel still uses old table: Invalid argument

And that's where I'm stuck, since a reboot throws me back to the initial partition state as described above in this post.

So, for some reason, I cannot paritition the sd card correctly.

Do you have any more hint on that issue ?

Thanx again for your assistance

Zigster
 
/dev/sda is a device.
And /dev/sda1 is a partition on it.

You must specify a DEVICE for fdisk command.
So this will be correct:
Code:
fdisk /dev/sda
 
@bbsc

yep! My fault on the fdisk command ... partitioning worked!

Rewalked all your steps, here's the output:

Code:
fdisk -l

Disk /dev/sda: 3963 MB, 3963617280 bytes
128 heads, 63 sectors/track, 960 cylinders
Units = cylinders of 8064 * 512 = 4128768 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1         960     3870688+ 83 Linux

...seems Ok

Code:
blkid
/dev/sda1: LABEL="SDCARD" UUID="13be324d-f345-402d-ac9e-3a66b820ebac"

...Ok too: labeled SDCARD

Code:
cat /jffs/scripts/init-start
#!/bin/sh

mkdir -p /tmp/opt

...looks the same as yours!

Code:
cat /jffs/configs/fstab
LABEL=SDCARD             /tmp/opt        ext2            rw,noatime      1 1

... as well: just like yours (with label SDCARD)

Code:
cat /jffs/scripts/services-start
#!/bin/sh

mount -obind /opt/home /tmp/home

...also just like your output!

...but upon reboot:
Code:
 mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock4 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /tmp/opt type ext2 (rw,noatime)

--> Not like yours!


Scripts are marked as executable too:

Code:
ll /jffs/scripts/
-rwxrwxrwx    1 admin    root            29 Feb 25 22:39 init-start*
-rwxrwxrwx    1 admin    root            44 Feb 25 22:39 services-start*

There must be a glitch on my part... but I'm blind....!!

Thanks again very much for your assistance...!

Zigster
 
Well, you'd better format that partition after fdisk:
Code:
mke2fs /dev/sda1

and make home directory on it after mounting on /tmp/opt:
Code:
mkdir -p /tmp/opt/home

Everything must work now after reboot.
 
Hi bbsc,

thanks for your reply.

disk was formatted, but I reformatted it again and created the directory.

Code:
ll /tmp//opt
drwxrwxrwx    2 admin    root            40 Feb 26 08:27 home/

But still, after reboot,mount shows just the mounting of /dev/sda1 on /tmp/mnt/sda1

Code:
admin@RT-N66U:/tmp/home/root# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock4 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /tmp/mnt/sda1 type ext2 (rw,nodev,noatime)

I wonder what the problem could be ...!

Thank you for your patience.

Zigster
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top