Genkey Ssh



Mendel Development Tool (MDT) is a command-line tool that lets you communicate with a device runningMendel Linux.

$ ssh-keygen -lf ided25519.pub 256 SHA256:PO2bk6B. It is unlikely that the recommend ED25519 SSH key is only 256 bits long. Linux ubuntu key ssh-keys openssh. DESCRIPTION top ssh-keygen generates, manages and converts authentication keys for ssh (1). Ssh-keygen can create keys for use by SSH protocol version 2. The type of key to be generated is specified with the -t option. Ssh-keygen -q -t rsa -N ' -f /.ssh/idrsa &1 /dev/null Or, under a bash like shell, If you certainly want to overwrite the previous one, use just a here-string to feed the command with all the need input: ssh-keygen -q -t rsa -N ' &1 /dev/null From ssh-keygen man page:-N newpassphrase provides the new passphrase.

The mdt commandfacilitates a variety of device actions such as opening a shell, installing Debian packages, pushingand pulling files, and more.

Install MDT

The server-side component that runs on your board is included with the Mendel system image.So you only need to install the mdt client on your host computer (Linux, macOS, or Windows 10).

You can install MDT on your host computer follows:

You might see a warning that mdt was installed somewhere that's not in your PATHenvironment variable. If so, be sure you add the given location to your PATH, as appropriate foryour operating system. If you're on Linux, you can add it like this:

Windows users:If you're using Git Bash, you'll need an alias to run MDT. Run this in your Git Bash terminal:

Connect to a board's shell

MDT can access the shell on any Mendel device that's visible on your network (as long as the devicealready has your OpenSSH key installed), or MDT can connect over USB when you connect your computerto the device, using the board's USB OTG port.

Mac users: Starting with macOS Catalina (10.15), you cannot create an MDT (or other SSH) connection over USB.MDT still works over your local network, but you need to first add an SSH key to the board, sofollow the instructions for MDT on macOS.

If you have just one device, run this command:

When you want to exit the shell, type exit.

Windows

When you connect to a board with mdt shell, it uses OpenSSH with key-based authentication(PEM-formatted and passwordless). The public key is saved on the board in/home/mendel/.ssh/authorized_keys and the private key is saved on your host computer in~/.config/mdt/keys/mdt.key (this key is used only when connecting with mdt shell). If the boarddoesn't have a key yet, mdt shell creates it and pushes it. For other MDT commands that helpmanage your keys, see all the MDT commands.

Connect to multiple boards

After you've connected to a board with MDT, you can reuse the same mdt.key file with additionalboards. It's just a matter of pushing this key to the authorized_keys file on each board:

  • If your additional board is newly flashed (or just unboxed), run mdt shell andit will push your existing MDT key from your computer's ~/.config/mdt/keys/mdt.key file.

  • If your additional board already has an MDT key in it's authorized_keys file, follow theinstructions to connect from multiple computers.

Then, you can list all available boards with mdt devices and connect by specifying the name(or IP address):

Connect to a board from multiple computers

Once you've connected to the board with one computer, you cannot immediately connect from anothercomputer because mdt shell will not push a new key if the board already has one in theauthorized_keys file (and if the mdt-keymaster service is not running).

To connect from additional computers, just copy the mdt.key file from thefirst computer and save it to ~/.config/mdt/keys/mdt.key on each computer you want to use.

If you don't have access to the first computer, see how torecover MDT access.

Recover MDT access

If you lose the private key stored at ~/.config/mdt/keys/mdt.key (such as by switchingcomputers) or you lose the public key on the Coral board, then MDT cannot connect.

To recover access with MDT, follow these steps:

  1. Connect to your board using the serial console (see the instruction for DevBoard or Dev Board Mini).

  2. On the board, delete the contents of the /home/mendel/.ssh/authorized_keys file.

  3. On the board, restart the mdt-keymaster service with this command:

  4. On your host computer, delete the ~/.config/mdt/keys/mdt.key file.

  5. Either connect to your computer to the board via USB or ensure both are on the same Wi-Fi network.

  6. On your host computer, generate a new key and connect:

Connect using other SSH tools

If you prefer to use other SSH tools, simply generate your own key and then push that oneto the device with mdt pushkey. For example, run the following on your host computer:

Generate Ssh Key Online

Note:This command requires that you already established a secure connection with `mdt shell`.

MDT commands

The following table provides a reference of the available commands you can use with mdt usingthis syntax:

You can also use mdt help and man mdtfor information about what commands are available in your version of MDT.

SubcommandDescription
devicesReturns a list of device names and IP addresses found on the local networksegment. Also indicates if a given device is marked as your default.

Uses the preferred-device variable, which contains the device name you want as your default. It can be set to an IPv4 address to bypass the mDNS lookup.

Note: MDT uses a python implementation of mDNS ZeroConf for discovery, soit does not require a running Avahi daemon.

wait-for-deviceWaits for a device to be discovered on the network.
get variable-nameReturns the value currently set for a given variable name. Some usefulvariables are:
  • preferred-device: Set this to your preferred device name to default most commands to manipulating this specific device. This can be set to an IPv4 address to bypass the mDNS lookup.
  • username: Set this to the username that should be used to connect to a device with. Defaults to 'mendel'.
  • password: Set this to the password to use to login to a new device with. Defaults to 'mendel'. Only used during the initial setup phase of pushing an SSH key to the board.

If no variable name is provided, mdt get will print out the list of allknown stored variables and their values, although it does not print default values.

set variable-nameSets the value for a given variable name. See example variables for the correspondingget command above.

Note that setting a variable to the empty string does not clear it back tothe default value. Use mdt clear for that.

clear variable-nameClears the value for a given variable name, resetting it back to itsdefault value.
genkeyGenerates an SSH key and saves it to the local machine (at ~/.config/mdt/keys/mdt.key).

If you already have an mdt.key file, this replaces it, effectively locking you outfrom any boards that require authentication with the previous key. Before you can re-push any newlygenerated keys, you must also remove the public key previously stored on the Mendel deviceand restart the mdt-keymaster service on the device by running mdt resetkeys.

To rotate your keys, call mdt resetkeys before this. Then call mdt pushkey after this.

pushkey path-to-ssh-public-keyCopies an SSH public key to the Mendel device's $HOME/.ssh/authorized_keys file. Ifan MDT private key is provided (the mdt.key file), this will push the public half ofthat key to the device's authorized_keys file. If no public key is provided, itattempts to push MDT's previously generated public key from$HOME/.config/mdt/keys/mdt.key.

To rotate your keys, call mdt genkey before this.

setkey path-to-private-keyCopies a PEM-format SSH private key into the Mendel device's MDT keystore for use withauthentication later.
resetkeys device-or-ip-addressResets a device to it's pre-MDT state by removing all MDT keys and restartingthe mdt-keymaster on the device so that new keys can be pushed again.

To rotate your keys, call mdt genkey after this.

shell [device-or-ip-address]Opens an interactive shell to either your preferred device or to the firstdevice found.If device-or-ip-address is specified, shell attempts to connect to thatdevice name or directly to the IP address provided instead.

Uses the variables preferred-device,username, and password (see the get command above).

If no SSH key is available on disk (you didn't run genkey before runningshell), this will implicitly run genkey for you. Additionally, it willattempt to connect to a device by doing the following:
1. Attempt a connection using your SSH key only, with no password.
2. If the connection attempt failed due to authentication, will attempt to push the key to the device by using the default login credentials in the 'username' and 'password' variables.
3. Installs your SSH key to the device after logging in.
4. Disconnects and reconnects using the SSH key.

exec [shell-command...]Opens a non-interactive shell to either your preferred device or to the firstdevice found, runs a shell command and returns the output and the exit code.

If no SSH key is available on disk, it follows the same steps as the shellcommand.

install deb-package-fileInstalls a given Debian package file to the connected device viamdt-install-package. Uses the variables preferred-device,username, and password (see the get command above).

Note: If the package provided has dependencies that are not already installed onthe device, this will require internet connectivity to fetch and install thosedependencies.

push local-path... [remote-path]Pushes (copies) a local file or set of files to the remote device. If you specify a directory forlocal-path, then that directory is added to the remote location and the contents arecopied recursively.

local-path may be an absolute path or a relative path.If you omit remote-path, MDT uses /home/mendel/. If youdo specify remote-path, it may be an absolute path or a path relative to/home/mendel/ (it must be an existing location). You should also verify thatremote-path does not match an existing path on your local machine, or else MDT interpretsit as a local-path argument and uses the default /home/mendel/ forremote-path.

Uses the variables preferred-device,username, and password (see the get command above).

pull remote-path...local-pathPulls (copies) a set of files from the remote device to a local path. If you specify a directoryfor remote-path, then that directory is added to the local location and the contents arecopied recursively.

remote-path may be an absolute path or a path relative to/home/mendel/. local-path may be an absolute path or a relative path (suchas . for the current directory).

Uses the variables preferred-device,username, and password (see the get command above).

rebootReboots a device.
reboot-bootloaderReboots a device to the bootloader and starts fastboot mode. After running this,you should see your device listed when you run fastboot devices, making it easy tothen flash the device (see how to flashthe Dev Board or the Dev BoardMini).
versionPrints which version of MDT this is.

MDT on macOS

Beginning with macOS Catalina (10.15), you cannot create an MDT (or other SSH) connection over USB.However, you can still use MDT over your local network—you just need to install an OpenSSH keyon your Coral board. Then your Mac can connect to the board over the local network.

So, here's how to create an SSH key and put it on your board using the serial console:

  1. Make sure your board is fully booted up.

  2. Connect a USB cable from your computer to the board's OTG port, and then run the following command in a terminal:

    You should see a device like this:

    'XXX' will be a number or your board's hostname.

  3. Connect to that device using a serial console program such as screen as follows:

    If the screen terminal is blank, press Enter and then you should see the login prompt.

  4. Log in using the username 'mendel' and password 'mendel'.

  5. In the serial console, create a new file for the public SSH key:

    Keep this serial console open while you create the SSH key...

  6. On your Mac, open another terminal and create a PEM-formatted SSH key pair:

    When prompted to enter a file name, type 'mendel', and leave the passphrase empty.

    This creates a private key called mendel and a public key called mendel.pub (in the currentdirectory).

  7. Set the file permissions and relocate the private key on your Mac as shown here:

  8. Now put the public key on the Coral board:

    1. In your Mac terminal, view the mendel.pub file (type cat mendel.pub) and copy the file contents.
    2. Go to the serial console and paste the key into the authorized_keys file you created above.
    3. Then save and close the authorized_keys file (in the VI editor, press ESC, then type :wqand press Enter.)

There you go! Now just make sure your Coral board is on the same local network as your Mac (get onthe same Wi-Fi) and you'll be able to use MDT from the Mac:

  1. To connect the board to Wi-Fi, run this command from the serial console:

  2. Then select Activate a connection and follow the UI to join the same network as your Mac.

  3. Finally, open a new terminal on your Mac and connect to the board:

Is this content helpful?

This chapter explains how to install Cygwin and start the SSH daemon on Microsoft Windows hosts. This chapter is applicable only when you want to install a Management Agent on a Microsoft Windows host, using the Add Host Targets Wizard or EM CLI. In particular, this chapter covers the following:

Important:

If you do not want to install Cygwin to deploy Management Agents on Microsoft Windows hosts using the Add Host Targets Wizard or EM CLI, you can choose to deploy Management Agents on these hosts using the PsExec process utility. For information on how to deploy Management Agents on Microsoft Windows hosts using PsExec, see Appendix F.

5.1About the Cygwin Requirement for Installing Management Agents

Ssh Keys Windows

The Add Host Targets Wizard is an application built into the Enterprise Manager Cloud Control console. It offers GUI-rich, interactive screens that enable you to install Oracle Management Agents (Management Agents) on unmanaged hosts and convert them to managed hosts, so that they can be monitored and managed in Enterprise Manager Cloud Control.

When you use the Add Host Targets Wizard or EM CLI to install a Management Agent on a host running on Microsoft Windows, as a prerequisite, you must install Cygwin and start the SSH Daemon on the host. To do so, follow the steps listed in Section 5.3.

Cygwin is essentially a utility that offers a Linux-like environment on a Microsoft Windows host. Technically, it is a DLL (cygwin1.dll) that acts as a Linux API layer providing substantial Linux API functionality. Once you install Cygwin, you can configure the SSH Daemon on the host. The Add Host Targets Wizard is certified and supported with Cygwin 1.7.

The SSH Daemon enables the Add Host Targets Wizard to establish SSH connectivity between the OMS host and the host on which you want to install a Management Agent. Using this connectivity, the wizard transfers the Management Agent software binaries to the destination host over SSH protocol, installs the Management Agent, and configures it.

5.2 Before You Begin Installing Cygwin

Before starting with the SSHD setup, ensure you are not using OpenSSH and MKSNT when using the Add Host Targets Wizard. To do so, perform the following checks:

  1. Ensure OpenSSHbin and mksnt are not in your PATH environment variable. If they are, remove them by doing the following:

    1. Right-click on My Computer and go to Properties.

    2. In the System Properties window, click Advanced.

    3. In this tab, click Environment Variables.

    4. Here, search for the PATH system variable, select it, and if the OpenSSHbin and mksnt are present in PATH, click Edit.

    5. In the Edit System Variable dialog box, delete these two values from PATH,then click OK.


  2. Stop the SSH Daemon if it is running from OpenSSH, MKS or any other vendor. If the SSH Daemon is running, stop it by doing the following:

    1. Right-click on My Computer, and select Manage.

    2. In the Computer Management window, in the left pane, expand Services and Applications, and select Services.

    3. In the right pane, click the SSH Daemon/MKS Secure Shell service, then click the Stop button.


Note:

The navigational steps described in this section may vary for different Microsoft Windows operating systems.

5.3 Installing Cygwin

To install Cygwin on a Microsoft Windows host, follow these steps:

  1. Access the following URL, then click Install Cygwin:

  2. Download the 32-bit version (if you are running a 32-bit version of Microsoft Windows) or the 64-bit version (if you are running a 64-bit version of Microsoft Windows) of the Cygwin setup executable.

  3. Run the setup executable, then click Next to proceed.


  4. On the Choose Installation Type screen, select Install from Internet, then click Next.


  5. On the Choose Installation Directory screen, enter C:cygwin as the Root Directory, then click Next.

    Note:

    If you choose to install Cygwin in a different directory, then ensure that you update the SSH_PATH, SCP_PATH, MKDIR_PATH, SH_PATH, CHMOD_PATH, and TRUE properties present in the $<OMS_HOME>ouiprovresourcesssPaths_msplats.properties file to their proper Cygwin binary values, after installing the Enterprise Manager system.

    For example, if you choose to install Cygwin in the D:softwarecygwin directory, then update the specified properties in the following manner:


  6. On the Select Local Package Directory screen, select a directory on your local machine where you want to store the downloaded installation files, then click Next.


  7. On the Select Connection Type screen, select appropriate settings to connect to the internet, then click Next.


  8. On the Choose Download Site(s) screen, select any site from the available list, then click Next.


  9. On the select packages screen, ensure that you select the following packages, then click Next:

    From the Archive category, select unzip and zip as follows:


    From the Net category, select openssh and openssl as follows:


    After selecting the packages and clicking Next, the Resolving Dependencies screen is displayed. Click Next to proceed.


  10. On the Installation Status and Create Icons screen, do not make any changes. Click Finish to complete the installation process.


5.4 Configuring SSH

This section describes how to configure SSH and test your Cygwin setup after installing Cygwin on a host.

Note:

While configuring SSH, you may need to run the cygwin.bat script. While running cygwin.bat in Microsoft Windows Server 2008 and Microsoft Windows Vista, ensure that you invoke it in administrator mode. To do this, right-click the cygwin.bat

Ssh-genkey Linux

file and select Run as administrator.

To configure SSH and test your Cygwin setup, follow these steps:

  1. After you install Cygwin, navigate to the C:cygwin directory, open the Cygwin.bat file in edit mode using any editor, and add the following line before invoking the bash shell.

    set CYGWIN=binmode ntsec

    For example, here are the contents for the Cygwin.bat file after adding the above line:

  2. To verify if Cygwin (cygrunsrv) is installed properly, run C:cygwinCygwin.bat, and execute the following command:

    If Cygwin is installed properly, then all the Cygwin help options are displayed on the screen. However, if this command returns an error message, then you may have to reinstall Cygwin.

  3. To configure the SSHD service, run C:cygwinCygwin.bat, and execute the following command:

    After running the command, you are prompted the following questions:

    At this point, if you want to use the same name, that is cyg_server, enter no. You are then prompted the following questions:

    However, if you want to use a different name, enter yes. You are then prompted the following questions:

    If the configuration is successful, you will see the following message:

  4. Backup the c:cygwinetcpasswd file and then use any editor to open the file in edit mode. Remove only those entries of the user that you will use to connect to the host on which you want to install a Management Agent. Ask the user to make a backup of the c:cygwinetcpasswd file before editing.

    • If the user that you are employing to connect to the host on which you want to install the Management Agent is a local user, run C:cygwinCygwin.bat and execute the following:

    • If the user you are employing to connect to the host on which you want to install the Management Agent running is a domain user, run C:cygwinCygwin.bat and execute the following:

  5. (Only if the Cygwin software you have installed is of version 1.7.32 or higher) Open C:cygwinetcsshd_config in a text editor and add the following line to the end of the file:

    KexAlgorithms diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

  6. (For a domain user only) If the user you are employing to connect to the host on which you want to install the Management Agent is a domain user, do the following to start the SSH daemon:

    1. Right-click on My Computer, and select Manage.

    2. In the Computer Management dialog box that appears, go to Services and Applications, and select CYGWIN sshd.

    3. Right-click CYGWIN sshd and select Properties.

    4. In the Properties dialog box, go to the Log On tab.

    5. Here, specify the domain/user name and password. Click Apply.

    6. Run C:cygwinCygwin.bat, and execute the following:

      Note:

      If /var/log/sshd.log does not exist, you do not have to execute the following commands:
  7. Perform one of the following steps to start the SSH daemon:

    Run C:cygwinCygwin.bat and execute the following command:

    /usr/sbin/sshd

    OR

    Run C:cygwinCygwin.bat and execute the following command:

    cygrunsrv -S sshd

    OR

    Perform these steps:

    1. Right-click on My Computer, and select Manage.

    2. In the Computer Management dialog box that appears, go to Services and Applications, and select CYGWIN sshd.

    3. Click CYGWIN sshd, then click the Start button.


    Note:

    If the SSH daemon does not start up, view the c:cygwinvarlogsshd.log file for information on why the start up failed.
  8. You can now test your Cygwin setup.

    To do this, go to a different machine (that has the ssh client running), and execute the following command:

    For example,

    This command will prompt you to specify the password. When you specify the correct password, the command should return the accurate date.

Note:

If you experience a process fork failure, memory leak error, or a file access error after configuring SSH, view the following website for a workaround:

If you are unable to find a workaround for your problem, report your problem to the Cygwin community using the following website:

5.5 After Installing Cygwin and Configuring SSH

After installing Cygwin (as described in Section 5.3) and configuring SSH (as described in Section 5.4), follow these steps:

  1. If the OMS host runs on a Microsoft Windows platform, perform the following on the OMS host:

    1. Right click My Computer, then select Properties. In the window that appears, select Advanced system settings, then select Environment Variables. In the System Variables section, create the CYGWIN variable, and specify its value as nodosfilewarning

      Note:

      You do not need to restart the host after performing this step.
    2. Navigate to the Cygwin install directory (that is, C:cygwin if you chose to install Cygwin in the default location), open the Cygwin.bat file in edit mode using any editor, then edit the following line:

      For example, these are the contents of the Cygwin.bat file after editing the above line:

    3. From the Start menu, select Run. For Open, enter services.msc, then click OK. Search for the Cygwin SSHD service and stop it.

    4. Navigate to the Cygwin install directory (that is, C:cygwin if you chose to install Cygwin in the default location), then run Cygwin.bat. Run the following command to start the SSHD service:

      Note:

      Running this command may return an error mentioning that /var/empty must be owned by the root user. If you encounter this error, run the following from the Cygwin terminal:

      After running this command, retry the $ /usr/sbin/sshd command.

  2. Perform the tasks mentioned in Step 1 on all the Microsoft Windows target hosts (on which you want to install Management Agents using the Add Host Targets Wizard or EM CLI).