Generate the private and public key pairs
- Open an SSH session to access the NI Linux Real-Time target shell using PuTTY .
- If you login as admin, change to lvuser account by executing su lvuser in the command line.
- As lvuser, execute ssh-keygen -t rsa to generate key pairs with RSA encryption.
- You can set a passphrase for the generated keys if desired. In this example, no passphrase was set.
- With default configuration, the identification (private key) is generated and saved at /home/lvuser/.ssh/id_rsa and public key is saved at /home/lvuser/.ssh/id_rsa.pub. Refer to the following figure.
Copy the public key to the remote SFTP server
If you can access to the server using password authentication, copy and paste the public key to the server using the
scp command (refer to the following figure). If you dont have the password to the SFTP server, follow the below steps to transfer the public key manually.
- View the id_rsa.pub by executing the following command cat /home/lvuser/.ssh/id_rsa.pub
- Copy the contents and paste it in on the SFTP server .ssh/authorized_keys located in the server home directory. Note that the authorized_keys directory may change depending on how the SFTP server is configured. The authorized_keys file in the server will keep the client's public key information as below figure.
Accessing the remote SFTP server using LabVIEW in NI Linux Real-Time target.
- Open LabVIEW's SFTP List Directory.vi shipping example and create a copy.
- Create an empty project and add NI Linux Real-time target (eg. Compact RIO).
- Place the copy of SFTP List Directory.vi under the real-time target in the LabVIEW project.
- Open the SFTP List Directory.vi block diagram and add OpenSSH client object and the Additional Options property node.
- Wire string array constant to the input of Additional Options property node specifying the path of the private keys after -i arguments. Refer to the below figure.