ssh

Connecting to Mongo database through SSH tunnel in Java

天大地大妈咪最大 提交于 2020-05-22 19:45:07
问题 FIXED (edited code to reflect changes I made) I'm trying to connect to a Mongo database through an SSH tunnel using Java. I'm using the Mongo driver 3.0.2 and jcraft (JSch) to create an SSH tunnel. The idea is that I: connect to the machine hosting the MongoDB installation through SSH set up port forwarding from a local port to the remote MongoDB port connect to MongoDB remotely My code looks like this: // forwarding ports private static final String LOCAL_HOST = "localhost"; private static

Paramiko ssh die/hang with big output

泪湿孤枕 提交于 2020-05-22 03:42:48
问题 I try to backup a server using Paramiko and ssh to call a tar command. When there is a limited number of files, all works well but when it's a big folder, the script wait endlessly. The following test shows me that the problem comes from the size of the stdout. Is there a way to correct that and execute this kind of command? Case big output: query = 'cd /;ls -lshAR -h' chan.exec_command(query) while not chan.recv_exit_status(): if chan.recv_ready(): data = chan.recv(1024) while data: print

Paramiko ssh die/hang with big output

社会主义新天地 提交于 2020-05-22 03:41:50
问题 I try to backup a server using Paramiko and ssh to call a tar command. When there is a limited number of files, all works well but when it's a big folder, the script wait endlessly. The following test shows me that the problem comes from the size of the stdout. Is there a way to correct that and execute this kind of command? Case big output: query = 'cd /;ls -lshAR -h' chan.exec_command(query) while not chan.recv_exit_status(): if chan.recv_ready(): data = chan.recv(1024) while data: print

Using java jcabi SSH client (or other) to execute several commands in shell

橙三吉。 提交于 2020-05-17 07:28:39
问题 I understand how to create a ssh shell Shell ssh = new SshByPassword("192.168.1.5", 22, "admin", "password"); i also understand how to run a command String output = new Shell.Plain(ssh).exec("some command"); and i can easly analyze the output string but how do i send in the same "shell" one command after the other and bonus question sometimes the commands require a user confirmation ("press Y to continue") is it possible with the library? 回答1: Generally, most Java SSH APIs leave it to the

User is reporting that they've unable to SSH into an EC2 instance in AWS?

不羁的心 提交于 2020-05-16 22:36:54
问题 The user's are doing the following: $ ssh -i /Users/user1/key.pem centos@10.12.10.10 The error message received while trying to access is as follows: $ ssh -i /Users/user1/key.pem centos@10.12.10.10 centos@10.12.10.10 : Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 回答1: A novel solution to this particular problem was presented by the AWS support and I felt compelled to share it here, since I hadn't seen it previously. In the past the method most of my colleagues have used

Mount NFS share via a hop server

我怕爱的太早我们不能终老 提交于 2020-05-16 22:05:47
问题 If we have a following situation: [laptop] ---- [host1] ---- [target] where host1 is reachable from the my laptop machine, the target from host1 only. We have ssh credentials to both host1 and target. On the target I have an nfs export with the following properties: /tmp/myshare 127.0.0.1/32(insecure,rw) As we can see, I can only mount it locally, from the target machine. I can set up a dynamic tunnel: ssh -J host1_user@host1 -D 127.0.0.1:8585 target_user@target but when trying: sudo

How to generate an ssh key for logging into a server without a password

a 夏天 提交于 2020-05-15 05:35:06
问题 I have used servers on amazon AWS where they send me a public key .pem file and when I ssh in, all I have to do is: ssh -i key.pem user@server I now have a server of my own and am trying to figure out how I can do this with my server so I can automate commands to my server via ssh. I imagine that I need to generate this key on my server and copy it to my client machine. How do I generate this key? 回答1: On the client machine you wish to login from , run ssh-keygen . For a quick and easy key,

Gitlab CE Doesn't Add a Public Key to authorized_keys

寵の児 提交于 2020-05-14 09:00:47
问题 I just installed the newest Omnibus Gitlab in CentOS 7. I have added my public key to my account but gitlab keeps prompting me for a password every time I try to connect using ssh, like ssh git@mygitlab.com . The git home folder is /var/opt/gitlab . Here are the various things that I've done: I have checked that write to authorized_keys is checked in the admin area -> settings -> network I have chmod the relevant folders and authorized_keys file. 0700 for home, 0711 for .ssh and 0600 for

Gitlab CE Doesn't Add a Public Key to authorized_keys

我们两清 提交于 2020-05-14 09:00:26
问题 I just installed the newest Omnibus Gitlab in CentOS 7. I have added my public key to my account but gitlab keeps prompting me for a password every time I try to connect using ssh, like ssh git@mygitlab.com . The git home folder is /var/opt/gitlab . Here are the various things that I've done: I have checked that write to authorized_keys is checked in the admin area -> settings -> network I have chmod the relevant folders and authorized_keys file. 0700 for home, 0711 for .ssh and 0600 for

Both display and save Plink output

假如想象 提交于 2020-05-14 01:06:12
问题 I'm logging into to a remote ssh session using plink.exe to perform certain tasks using a batch script. Getting the output of these commands in a log file as well on the screen is very important for me. I tried using usual batch way i.e. plink servername -m cmd.txt>logfile.log way but the problem with this is that it won't display it on the Windows terminal that the batch script is running on. Then I found the -sshlog option of Plink. This does the work, i.e. I can get the output but on