upload file to sftp from jenkins - bash

My task is automate uploading file to sftp server by using Jenkins CI.
My permissions is very limited and I have no access to sftp server via ssh.
I have tried to use sftp bash command but have a problem with automation input password (expect can not be installed)
Curl also have problems :
curl --insecure -vvv -T filename.xml -u user:password sftp://server.com:XXXX
* About to connect() to server.com port XXXX (#0)
* Trying xxx.xxx.xxx.xxx... connected
* Connected to server.com (xxx.xxx.xxx.xxx) port XXXX (#0)
* SSH authentication methods available: publickey,password
* Using ssh public key file /home1/user/.ssh/id_dsa.pub
* Using ssh private key file /home1/user/.ssh/id_dsa
* SSH public key authentication failed: Unable to open public key file
* Initialized password authentication
* Authentication complete
* Upload failed: Permission denied (3/-31)
Connection #0 to host server.com left intact
curl: (9) Upload failed: Permission denied (3/-31)
* Closing connection #0
Can you help me to find another way or resolve my problem?
Thank you.

'My permissions is very limited and I have no access to sftp server
via ssh.'
If you can't access the server via SSH, any SSH based authentication system isn't going to work. Your public key can't be opened, so check that it's the correct file path to the public key and that it's the right type of key. Should start with "-----BEGIN RSA PRIVATE KEY-----" and end with the same comment.

Related

Ansible Failed to connect to the host via ssh

good day.
I generated ssh-keygen via user not in root and I copied it to my remote server. I can ssh the remote server without asking for a password in the user. As far as I read from the documentations it needs to have generated ssh-key in root in order to run commands like this:
ansible all -m ping
Is there a way that I can get to this successfully without using root?
For now, I get this error:
"msg": "Failed to connect to the host via ssh: <username>#192.x.y.z: Permission denied (publickey,password).",

Jmeter SSH SFTP using ppk file

I have to drop file in SFTP location and SFTP has ppk file instead password. I tried SSH SFTP with SSH key file locating to ppk file. But i am getting invalid primary key. Can you please help
SSH SFTP Sampler expects Putty Private Key, if you try to use OpenSSH id_rsa private key - you will get something like Failed to connect to server: invalid privatekey: [B#somehexvalues] error
If your private key starts with -----BEGIN OPENSSH PRIVATE KEY----- - you won't be able to use it with SSH SFTP sampler
If your private key starts with PuTTY-User-Key-File-2: ssh-rsa - you will be able to use it (assuming the server has the corresponding public key)
If you need to convert OpenSSH or RSA private key to Putty PPK - use PyttyGen application.
More information: Load Testing FTP and SFTP Servers Using JMeter

Unable to connect to EC2 server with my MacBook

I am unable to connect to EC2 (CentOs) from my MacBook. When I connect it from ubuntu machine, it will be connected. Currently, I got the following the following error:
ec2 ssh sign_and_send_pubkey: no mutual signature supported Account locked due to 290 failed logins
How can I solve the problem?
I have tried the following command:
ssh -i key.pem ec2-user#ip
I was locked out and couldn't access the machine to enter in the suggested answer's change to ssh config.
I added the following argument to the ssh call -o PubkeyAcceptedKeyTypes=+ssh-rsa and it worked.
Example:
ssh -i "keypair.cer" -o PubkeyAcceptedKeyTypes=+ssh-rsa ec2-user#ip
Note: the ssh call will accept both .cer and .pem filetypes.
edit or create the file ~/.ssh/config and add the following content:
Host *
PubkeyAcceptedKeyTypes=+ssh-dss
After that, try again.

Setup passphraseless ssh to localhost on OS X

I'm trying to get Hadoop's Pseudo-Distributed Operation example (http://hadoop.apache.org/common/docs/stable/single_node_setup.html) to work on OS X Lion, but am having trouble getting the ssh to work without a passphrase.
The instructions say the following:
Setup passphraseless ssh
Now check that you can ssh to the localhost without a passphrase: $
ssh localhost
I'm getting connection refused:
archos:hadoop-0.20.203.0 travis$ ssh localhost
ssh: connect to host localhost port 22: Connection refused
If you cannot ssh to localhost without a passphrase, execute the
following commands:
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
After this step I am still getting connection refused. Any ideas???
Sounds like you don't have SSH enabled. Should be in the network settings control panel somewhere.
You go to "System Preferences > Sharing > Remote Access" and there's a list of authorized users. Change it to "All Users".
That's solves this problem.
Check the permissions on your .ssh directory. Some ssh implementations require that the directory be chmod 700. Otherwise, they just ignore it.
Also, check the output of
ssh -v localhost
to see how the ssh client is trying to connect. The output is very detailed, and will help you decide if it's an authentication problem.
I had the same issue.
Please check if the ssh server is running or not.
If yes, open the /etc/init.d/ssh_config and /etc/init.d/sshd_config files. The issue is that the server is running on a different port and the client is pointing to different port.
Before this please ensure that openssh-server and client are installed.
I had the same problem and i solved it the following manner :
SSH is activated.
ssh -v localhost (as stated by Herko)
In the ouput, i identified that the authentication method by DSA is not supported.
debug1: Skipping ssh-dss key /Users/john/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
I simply re-generate an ECDSA keys and remove the DSA key pairs.
After the keys generation, the procedure given on Hadoop documentation holds.
Therefore, it is important to check, if the authentication method is supported by the Openssh configuration.

ssh to amazon EC2 over proxy

I have some problem connecting to my amazon EC2 server over ssh over proxy.
I have my username and password for http proxy port 8080.(dont have control over proxy)
Also I have my connection string which would work without proxy
ssh -i key.pem root#xx.compute.amazonaws.com
when I am trying to connect I am getting "No route to host" error
I tried to use putty, configured proxy + authentication file, But then I getting this error
"Unable to use this key file (OpenSSH SSH-2 private key)"
Also I dont know how putty inserts my proxy config, into ssh connection string, so I could try it in terminal
I was facing the same problem and this is what I used to connect, using corkscrew. My config file looks like this
Host AWS
Hostname <Public DNS>
Port 443
#Write the appropriate username depending on your AMI, eg : ubuntu, ec2-user
User ubuntu
IdentityFile </path to key file>
ProxyCommand /usr/bin/corkscrew 10.10.78.61 3128 %h %p
then I simply use this command to connect
ssh AWS
and it works flawlessly.
Note : You must edit your sshd_config file on the server to listen to ssh connections on port 443 (in addition to 22) and restart the ssh daemon.
Are you sure you can login as root? Try logging in as ec2-user instead.
Also, if you have assigned an elastic IP to your instance, the public DNS has probably changed. Log in to the aws console, and select your instance. Scroll down to look at the public DNS again and double check you are using the correct xx.compute.amazonaws.com addr.

Resources