SSH – Load key “/Users/username/.ssh/id_rsa.pub”: invalid format

Suddenly the git push via SSH failed, and the remote server returned something like invalid format for the public key id_rsa.pub? Terminal git push Load key "/Users/username/.ssh/id_rsa.pub": invalid format [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Last week, …

Read more

Java – Run shell script on a remote server

This article shows how to use JSch library to run or execute a shell script in a remote server via SSH. pom.xml <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.55</version> </dependency> 1. Run Remote Shell Script This Java example uses JSch to SSH login a remote server (using password), and runs a shell script hello.sh. 1.1 Here is a …

Read more

File Transfer using SFTP in Java (JSch)

This article shows how to do file transfer from a remote server to the local system and vice versa, using SSH File Transfer Protocol (SFTP) in Java. P.S Tested with JSch 0.1.55 1. JSch Dependency pom.xml <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.55</version> </dependency> 2. File Transfer – JSch Examples 2.1 In JSch, we can use put and …

Read more

Jsch – UnknownHostKey exception

This Java example tries to use Jsch to download a file from a remote server to the local system. pom.xml <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.55</version> </dependency> SFTPFileTransfer.java package com.mkyong.io.howto; import com.jcraft.jsch.*; public class SFTPFileTransfer { private static final String REMOTE_HOST = "1.1.1.1"; private static final String USERNAME = ""; private static final String PASSWORD = ""; …

Read more

JSch – invalid privatekey exception

This Java example tries to use JSch to transfer a file from the local folder to a remote server using public and private keys, instead of a password. pom.xml <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.55</version> </dependency> SFTPFileTransfer.java package com.mkyong.io.howto; import com.jcraft.jsch.*; public class SFTPFileTransfer { private static final String REMOTE_HOST = "1.1.1.1"; private static final String USERNAME …

Read more

How to check OpenSSH version

On Linux, macOS, or Windows, we can use ssh -V (uppercase V) to check the OpenSSH version currently installed. Example 1 Terminal $ ssh -V OpenSSH_9.0p1, LibreSSL 3.3.6 Example 2 Terminal $ ssh -V OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n 15 Mar 2022 References Wikipedia – OpenSSH OpenSSH Release Notes

Multiple SSH private keys Examples

To allow multiple private keys connect to different servers, edit ~/.ssh/config : ~/.ssh/config Host 10.10.10.1 IdentityFile ~/.ssh/linode_rsa Host 200.20.20.2 IdentityFile ~/.ssh/id_rsa If you SSH to 10.10.10.1, private key ~/.ssh/linode_rsa will be used. If you SSH to 200.20.20.2, private key ~/.ssh/id_rsa will be used. 1. Single Private Key for Multiple Servers 1.1 You have following public …

Read more

Download file from server using SSH

Normally, you use Secure copy or SCP to download a file from another server via SSH connection. For example, scp username@remotehost:remoteFileToDownload localFolderNameToSaveTheFile 1. SCP Examples 1.1 Download File From Server Example to download a log file (hc.audit.log) from server (198.58.x.x), into your current local folder. scp [email protected]:/var/log/tomcat7/hc.audit.log . 1.2 Upload File To Server Example to …

Read more

svn+ssh hit Connection closed unexpectedly error in Eclipse – (Solution)

Latest Eclipse IDE is required to support the hibernate tools plug-in. However my “svn+ssh” is not working correctly after updated to the latest Eclipse IDE and Subeclipse version of 1.6.x. While i initial the “svn+ssh” access connection in Eclipse IDE, i had encountered the following error message. Network connection closed unexpectedly svn: Connection closed unexpectedly …

Read more