Oracle Cloud Permission denied (publickey)
I have a problem with the connection to the server. Yesterday everything was working great and I could connect with my keys. Every time I try to connect I get Permission denied (publickey).
I tried to: ssh ubuntu@ip -i file But it didn't help.
How can I resolve this problem?
do you know?
how many words do you know
See also questions close to this topic
-
Why doesn't systemd start my autossh tunnel on reboot?
I have a PC that I need to ssh into which only has a private IP (running Ubuntu 20.04 LTS). This is my first time working with autossh and systemd. I have autossh working and I can easily create a tunnel and ssh into the PC from my server (which has a public ip).
I have noticed that the ssh tunnel will randomly close despite having ServerAliveInterval 30 and ServerAliveCountMax 3 values. I have been fixing this my manually deleting the tunnel on both the PC and server, and then creating it all over again. But this is a temporary solution since ideally I would want the tunnel to come back by itself. I believe the tunnel closes to either the network dropping and coming back up, but I am not sure why. Here is the systemd service I created on the PC:
tunnel-up.service (192.168.1.111 is the fake public IP of the server)
[Unit] Wants=network-online.target After=network-online.target [Service] Type=oneshot ExecStart=autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NT -o Tunnel=point-to-point -w 1:1 192.168.1.111 & ExecStart=/bin/bash /root/scripts/link-up.sh [Install] WantedBy=multi-user.target
link-up.sh
#!/bin/bash ip link set tun1 up && ip addr add 10.250.0.3/30 peer 10.250.0.4 dev tun1
I have done systemctl daemon-reload and systemctl start tunnel-up.service but when I reboot my computer the tunnel never gets created... I had the autossh command inside my link-up.sh script and when I executed the script it worked perfectly, however when it comes to running this on startup it never works. Any help would be appreciated.
Here is the output of journalctl -u tunnel-up.service
May 06 17:42:18 hmtest.ut systemd[1]: Starting tunnel-up.service... May 06 17:42:18 hmtest.ut autossh[1067]: port set to 0, monitoring disabled May 06 17:42:18 hmtest.ut autossh[1067]: starting ssh (count 1) May 06 17:42:18 hmtest.ut autossh[1067]: ssh child pid is 1077 May 06 17:42:18 hmtest.ut autossh[1077]: ssh: connect to host 192.168.1.111 port 22: Network is unreachable May 06 17:42:18 hmtest.ut autossh[1067]: ssh exited prematurely with status 255; autossh exiting May 06 17:42:18 hmtest.ut systemd[1]: tunnel-up.service: Main process exited, code=exited, status=1/FAILURE May 06 17:42:18 hmtest.ut systemd[1]: tunnel-up.service: Failed with result 'exit-code'. May 06 17:42:18 hmtest.ut systemd[1]: Failed to start tunnel-up.service.
-
Running a Python Flask server in closed Terminal session
I've made an Flask API Server that i want to run on a Server and close the Terminal session and still keep it running. (SSH) The API's makes a lot of Requests to other servers and uses Threading to make this Process faster.
I've tried the setsid command, and this works fine until i close the Terminal session. Because when its closed, i am only getting 500 errors.
-
Unable to Connect to SFTP through paramiko
I am trying to establish a connection with an SFTP with paramiko. I was able to generate the known_hosts file in my local system by using
ssh my.domain.com
The resultant file has both the host and its IP in the first line of known_hosts, like
my.domain.com,xx.xx.xxx.xx ...
When I try to connect through paramiko,
host, port = 'my.domain.com,xx.xx.xxx.xx', 22 user, pwd = "xyz", "abc" ssh = paramiko.SSHClient() ssh.connect(host, port, username=user, password=pwd)
I get the error
socket.gaierror: [Errno 11001] getaddrinfo failed
After looking this up, the solutions were to not mention user in host or add port, etc. But I'm still not able to connect. I tried removing
my.domain.com
from both the Python code and known_hosts file,host, port = 'xx.xx.xxx.xx', 22 user, pwd = "xyz", "abc" ssh = paramiko.SSHClient() ssh.connect(host, port, username=user, password=pwd)
but that didn't work. I tried removing
xx.xx.xxx.xx
from both the Python code and known_hosts file,host, port = 'xx.xx.xxx.xx', 22 user, pwd = "xyz", "abc" ssh = paramiko.SSHClient() ssh.connect(host, port, username=user, password=pwd)
but that didn't work either.
How do I connect to my SFTP?
-
How to change the ssh port connection on Windows?
I am trying to connect to GitLab with an ssh key from a Windows laptop. The problem is the port of the repository has changed, and I cannot manage to change the default port 22 on the config.
I have tried with a mac laptop and it worked by editing the config file, but I cannot do the same on Windows. I created a config file with
touch config
and added thisHost gitlab.com HostName gitlab.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa Port 1122
But it does not work, terminal says it is still connecting to port 22:
C:\Users\parko>ssh -T git@gitlab.com kex_exchange_identification: read: Connection reset C:\Users\parko>ssh -T git@gitlab.%myRepository%.com ssh: connect to host gitlab.%myRepository%.com port 22: Connection timed out
I also tried a solution that I found in an article to change the port directly on the command when trying to connect, but it also did not work:
C:\Users\parko>ssh -T git@gitlab.%myRepository%.com:1123 ssh: Could not resolve hostname gitlab.%myRepository%.com:1123: No such host is known.
Any idea what can be happening? Thanks in advance.
-
SSH key not working for git push unless recently logged in
Background
I use SiteGround to host my websites. I have git repos set up for each of my sites on SiteGround. I use SSH keys for authentication. I just set siteground to be one of my remotes that I can push too.
The problem
The SSH keys appear to expire after a while, unless I login via SSH. I haven't been able to determine how long it takes before expiration. It seems to be a few weeks.
Procedure
- Wait a few weeks.
- Make some modifications to my website, commit and merge to
main
. $ git push sitegroundRemote HEAD:master
Then I get this error:
$ git push sitegroundRemote HEAD:master <username>@subdomain.siteground.biz: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
$ ssh sitename
<-- this works. I'm now logged into a remote session$ exit
$ git push sitegroundRemote HEAD:master
And now it works. And I can continue to push for the next few days or weeks without having to
ssh
in.It seems like the key expires for git purposes, but not logging into the shell. And logging into the shell re-enables the key to be used for git purposes.
Additional Info
SSH config
The entry in my ~/.ssh/config file looks like:
Host sitename HostName sitename.com User <user-name> Port <port-number> IdentityFile ~/.ssh/sitename.com
git config
The entry in my git config file looks like:
[remote "sitegroundRemote"] url = ssh://<user-name>@<subdomain>.siteground.biz:<port>/home/<user-name>/www/sitename.com/repos/repo.git fetch = +refs/heads/*:refs/remotes/master/*
Generating the SSH key
To generate my SSH key, I did the following:
$ ssh-keygen
- Entered location and name and password (
/Users/username/.ssh/sitename.com
) $ ssh-add -K /Users/username/.ssh/sitename.com
$ pbcopy < ~/.ssh/sitename.com.pub
- Paste that into SiteGround's SSH key section.
All of this allows me to just
$ ssh sitename
to gain access to my site via bash. So the key works. I didn't use any-t
options to put a time limit on it or anything.The question
Any idea how I can continue to push to SiteGround without having to login every so often?
I should add that I did contact SiteGround's support, and the answer was basically "Sessions expire. There's nothing we can do about it." So I'm hoping someone here has some ideas.
-
How to authorize Rest API in Oracle Cloud?
I am creating a web application where users has option to connect to
Oracle Cloud
. After authenticating to oracle, our application will call api of oracle cloud.As i know we can create a oauth2.0 application but it will be only available within same tenant where it is created. Is there any other way so that any users can connect to our application using there oracle cloud account?
-
How do I create a snapshot of a VM in Oracle Cloud (OCI)?
I recently set up a Ubuntu Linux instance in Oracle Cloud. I'm used to take snapshots of VM's so I can roll back if something later goes wrong. In Digitalocean (droplet) this is as simple as pressing a button but in Oracle Cloud I can't seem to find this functionality. I've read documentation and Googled but to no avail. Also seems Oracle have several different cloud offerings with similar naming which makes it hard to find relevant information.
-
terraform create pem file
i'm new to terraform.
i try to make simple terraform code with aws.
it works well. i can see ec2 and security group, eip.
i want to access instance but i don't have .pem file.
so it make me hard to connect ec2.
how to get .pem file?
can anyone let me know please?
resource "aws_key_pair" "alone_ec2" { key_name = "alone_ec2" public_key = file("~/.ssh/id_rsa.pub") } resource "aws_security_group" "alone_web" { name = "Alone EC2 Security Group" description = "Alone EC2 Security Group" ingress { from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["${chomp(data.http.myip.body)}/32"] } ingress { from_port = 8080 to_port = 8080 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } ingress { from_port = 443 to_port = 443 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } } # EC2 resource "aws_instance" "web" { ami = "ami-02de72c5dc79358c9" instance_type = "t2.micro" key_name = aws_key_pair.alone_ec2.key_name vpc_security_group_ids = [ aws_security_group.alone_web.id ] tags = { Name = "example-webservice" } root_block_device { volume_size = 30 } } # EIP resource "aws_eip" "elasticip" { instance = aws_instance.web.id } output "EIP" { value = aws_eip.elasticip.public_ip }
-
Compute Diffie-Hellman key pair and shared secret in iOS with Swift
I need on iOS with Swift to:
- Generate a Diffie–Hellman key pair with a pre-agreed modulus P and a base G
- Compute a shared secret with a local private key, a remote public key and pre-agreed modulus P
And this without Elliptic-curve Diffie–Hellman (ECDH).
I wrote this code using BigInt repository.
/// Diffie–Hellman key pair struct DHKeyPair { var privateKey: Data var publicKey: Data init(privateKey: Data, publicKey: Data) { self.privateKey = privateKey self.publicKey = publicKey } } /// Generate a Diffie–Hellman key pair /// /// - Parameter modulus: Diffie-Hellman modulus P /// - Parameter base: Diffie-Hellman base G /// - Returns: DH key pair, or nil on error static func generateDhKeyPair(modulus: Data, base: Data) -> DHKeyPair? { // Modulus let modulusBigUInt = BigUInt(modulus) // Base let baseBigUInt = BigUInt(base) // Generate random private key guard let privateKey = Crypto.randomBytes(length: 512) else { return nil } let privateKeyBigUInt = BigUInt(privateKey) // Compute public key let publicKeyBigUInt = baseBigUInt.power(privateKeyBigUInt, modulus: modulusBigUInt) var publicKey = publicKeyBigUInt.serialize() // Set Diffie-Hellman key pair let dhKeypair = DHKeyPair(privateKey: privateKey, publicKey: publicKey) return dhKeypair } /// Compute a shared secret based on local pair key (public/private) and remote public key /// /// - Parameter privateKey: Private key /// - Parameter remotePublicKey: Remote public key /// - Parameter modulus: Diffie-Hellman modulus P /// - Returns: the computed shared secret static func computeSharedSecret(privateKey: Data, remotePublicKey: Data, modulus: Data) -> Data { // Private key let privateKeyBigUInt = BigUInt(privateKey) // Remote public key let remotePublicKeyBigUInt = BigUInt(remotePublicKey) // Modulus let modulusBigUInt = BigUInt(modulus) // Compute shared secret let sharedSecretBigUInt = remotePublicKeyBigUInt.power(privateKeyBigUInt, modulus: modulusBigUInt) var sharedSecret = sharedSecretBigUInt.serialize() return sharedSecret }
It's well working but it takes too long, about 50 seconds to generate the key pair, and the same to compute the shared secret. This is because of the BigUInt modular exponentiation function (see doc).
I couldn't find anything for these operations in the Keys documentation of the API for Swift.
So how can I do these Diffie-Hellman operations faster? Can it be done also with Swift API?
PS: we've the same function on the JDK which takes just a few seconds.