Skip to content

Tips

SSH for remote control

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line login and remote command execution, but any network service can be secured with SSH.

Advanced options

  • Disable host key checking: ssh -o StrictHostKeyChecking=no
  • Redirect known host file (~/.ssh/known_hosts) to /dev/null:
    ssh -o UserKnownHostsFile=/dev/null
  • Execute scripts in remote machine:
    ssh user@host <<'ENDSSH'  
        #commands to run on remote host  
    ENDSSH

Example ssh root@10.61.61.195 "echo 1 > ~/test". This command will remote to root@10.61.61.195 machine and then execute "echo 1 > ~/test"

  • Auto-generate password for ssh
    echo "#!/bin/sh" >> /tmp/genpass.sh
    echo "echo $pass" >> /tmp/genpass.sh
    export SSH_ASKPASS="/tmp/genpass.sh" && export DISPLAY=
    setsid ssh root@10.61.61.195

? setsid: what is this?

See more at Bash Script SSH Automation Without a Password Prompt.

Example commands

timeout 20 setsid ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null

References

More information about SSH config can be found at https://linux.die.net/man/5/ssh_config

TFTP Server

Trivial File Transfer Protocol (TFTP) is a simple lockstep File Transfer Protocol which allows a client to get a file from or put a file onto a remote host (Wiki).

TFTP uses UDP as its transport protocol.

Install TFTP server

With Ubuntu machine, install tftp by installing following packages:

sudo apt-get install xinetd tftpd tftp

Build tftp server for embedded system: How to build?

Configure TFTP server

Create /etc/xinetd.d/tftp and put this entry

service tftp
{
protocol        = udp
port            = 69
socket_type     = dgram
wait            = yes
user            = nobody
server          = /usr/sbin/in.tftpd
server_args     = /tftpboot
disable         = no
}

Create a folder /tftpboot this should match whatever you gave in server_args. mostly it will be tftpboot

sudo mkdir /tftpboot
sudo chmod -R 777 /tftpboot
sudo chown -R nobody /tftpboot

Restart the xinetd service.

  • newer systems:

sudo service xinetd restart

  • older systems:

sudo /etc/init.d/xinetd restart

Testing tftp server

Create a file named test with some content in /tftpboot path of the tftp server. Obtain the ip address of the tftp server using ifconfig command.

Now in some other system (client - which want to get file) follow the following steps.

tftp 192.168.1.2 # tftp server ip
tftp> get test
Sent 159 bytes in 0.0 seconds

tftp> quit

cat test

BusyBox

Removable Disk

Remount SD Card for clear Read-only Flag

Sometimes, your SD card in someways is mounted in Read-only mode. In this case, you can not modify anything stored in these memory. To solve this problem, just re-mount its.

  • Use sudo fdisk -l for show all disk
  • Remount SD Card with folow command: sudo mount /dev/sdc -o remount,rw

Backup SD card image

Method 1: Command line

Refer at: https://stackoverflow.com/questions/19355036/how-to-create-an-img-image-of-a-disc-sd-card-without-including-free-space

Back up

sudo dd if=/dev/mmcblk0 | gzip > /tmp/sdimage_backup.img.gz

Restore

cat backup.img.gz | gunzip | dd of=/dev/sdb

Method 2: Disks utility in Ubuntu

Using Google Drive in Ubuntu

https://linuxconfig.org/google-drive-on-ubuntu-18-04-bionic-beaver-linux

Back to top